auto-patch 673-dev-dev01-2024-05-25T22_41_57
This commit is contained in:
@@ -439,6 +439,9 @@ class WC_Helper_Updater {
|
||||
* @return array Update data for each requested product.
|
||||
*/
|
||||
private static function _update_check( $payload ) {
|
||||
if ( empty( $payload ) ) {
|
||||
return array();
|
||||
}
|
||||
ksort( $payload );
|
||||
$hash = md5( wp_json_encode( $payload ) );
|
||||
|
||||
|
||||
@@ -252,6 +252,9 @@ class WC_Install {
|
||||
'wc_update_890_update_connect_to_woocommerce_note',
|
||||
'wc_update_890_update_paypal_standard_load_eligibility',
|
||||
),
|
||||
'8.9.1' => array(
|
||||
'wc_update_891_create_plugin_autoinstall_history_option',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1187,16 +1190,30 @@ class WC_Install {
|
||||
return;
|
||||
}
|
||||
|
||||
// Did we previously install this plugin?
|
||||
// We check both the woocommerce_history_of_autoinstalled_plugins options (introduced in 9.0)
|
||||
// and the woocommerce_autoinstalled_plugins option (info should still exist here if the plugin has been uninstalled but not manually reinstalled).
|
||||
$legacy_api_plugin = 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php';
|
||||
$autoinstalled_plugins = (array) get_site_option( 'woocommerce_history_of_autoinstalled_plugins', array() );
|
||||
$previously_installed_by_us = isset( $autoinstalled_plugins[ $legacy_api_plugin ] );
|
||||
if ( ! $previously_installed_by_us ) {
|
||||
$autoinstalled_plugins = (array) get_site_option( 'woocommerce_autoinstalled_plugins', array() );
|
||||
$previously_installed_by_us = isset( $autoinstalled_plugins[ $legacy_api_plugin ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter to skip the automatic installation of the WooCommerce Legacy REST API plugin
|
||||
* from the WordPress.org plugins directory.
|
||||
*
|
||||
* By default, this is true (skip installation) if we have a record of previously installing the legacy plugin,
|
||||
* and false (do not skip) if we have no record of previously installing the plugin.
|
||||
*
|
||||
* @since 8.8.0
|
||||
*
|
||||
* @param bool $skip_auto_install False, defaulting to "don't skip the plugin automatic installation".
|
||||
* @returns bool True to skip the plugin automatic installation, false to install the plugin if necessary.
|
||||
*/
|
||||
if ( apply_filters( 'woocommerce_skip_legacy_rest_api_plugin_auto_install', false ) ) {
|
||||
if ( apply_filters( 'woocommerce_skip_legacy_rest_api_plugin_auto_install', $previously_installed_by_us ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1205,19 +1222,17 @@ class WC_Install {
|
||||
return;
|
||||
}
|
||||
|
||||
$plugin_name = 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php';
|
||||
|
||||
wp_clean_plugins_cache();
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
if ( isset( get_plugins()[ $plugin_name ] ) ) {
|
||||
if ( ! ( get_site_option( 'woocommerce_autoinstalled_plugins', array() )[ $plugin_name ] ?? null ) ) {
|
||||
if ( isset( get_plugins()[ $legacy_api_plugin ] ) ) {
|
||||
if ( ! $previously_installed_by_us ) {
|
||||
// The plugin was installed manually so let's not interfere.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( in_array( $plugin_name, wp_get_active_and_valid_plugins(), true ) ) {
|
||||
if ( in_array( $legacy_api_plugin, wp_get_active_and_valid_plugins(), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1248,7 +1263,7 @@ class WC_Install {
|
||||
$site_logs_url = get_admin_url( null, '/admin.php?page=wc-status&tab=logs' );
|
||||
|
||||
if ( $install_ok ) {
|
||||
$activation_result = activate_plugin( $plugin_name );
|
||||
$activation_result = activate_plugin( $legacy_api_plugin );
|
||||
if ( $activation_result instanceof \WP_Error ) {
|
||||
$message = sprintf(
|
||||
/* translators: 1 = URL of Legacy REST API plugin page, 2 = URL of Legacy API settings in current site, 3 = URL of webhooks settings in current site, 4 = URL of logs page in current site, 5 = URL of plugins page in current site, 6 = URL of blog post about the Legacy REST API removal */
|
||||
|
||||
@@ -41,7 +41,7 @@ final class WooCommerce {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '8.9.0';
|
||||
public $version = '8.9.1';
|
||||
|
||||
/**
|
||||
* WooCommerce Schema version.
|
||||
|
||||
@@ -94,29 +94,22 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust
|
||||
* @param array $allowed_keys The allowed meta data keys.
|
||||
* @param WC_Customer $customer The customer object.
|
||||
*/
|
||||
$allowed_keys = apply_filters( 'woocommerce_customer_allowed_session_meta_keys', array(), $customer );
|
||||
$session_value = maybe_serialize(
|
||||
array_map(
|
||||
function ( $meta_data ) {
|
||||
// Data comes to us a WC_Meta_Data, we cast it to an array to ensure it is serializable.
|
||||
return array(
|
||||
'key' => $meta_data->key,
|
||||
'value' => $meta_data->value,
|
||||
);
|
||||
},
|
||||
array_filter(
|
||||
$customer->get_meta_data(),
|
||||
function ( $meta_data ) use ( $allowed_keys ) {
|
||||
return in_array( $meta_data->key, $allowed_keys, true );
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
$allowed_keys = apply_filters( 'woocommerce_customer_allowed_session_meta_keys', array(), $customer );
|
||||
|
||||
$session_value = array();
|
||||
foreach ( $customer->get_meta_data() as $meta_data ) {
|
||||
if ( in_array( $meta_data->key, $allowed_keys, true ) ) {
|
||||
$session_value[] = array(
|
||||
'key' => $meta_data->key,
|
||||
'value' => $meta_data->value,
|
||||
);
|
||||
}
|
||||
}
|
||||
$data['meta_data'] = $session_value;
|
||||
} else {
|
||||
$session_value = $customer->{"get_$function_key"}( 'edit' );
|
||||
$session_value = $customer->{"get_$function_key"}( 'edit' );
|
||||
$data[ $session_key ] = (string) $session_value;
|
||||
}
|
||||
$data[ $session_key ] = (string) $session_value;
|
||||
}
|
||||
WC()->session->set( 'customer', $data );
|
||||
}
|
||||
@@ -147,9 +140,8 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust
|
||||
}
|
||||
if ( ! empty( $data[ $session_key ] ) && is_callable( array( $customer, "set_{$function_key}" ) ) ) {
|
||||
if ( 'meta_data' === $session_key ) {
|
||||
$meta_data_values = maybe_unserialize( $data[ $session_key ] );
|
||||
if ( $meta_data_values ) {
|
||||
foreach ( $meta_data_values as $meta_data_value ) {
|
||||
if ( is_array( $data[ $session_key ] ) ) {
|
||||
foreach ( $data[ $session_key ] as $meta_data_value ) {
|
||||
if ( ! isset( $meta_data_value['key'], $meta_data_value['value'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2710,3 +2710,17 @@ function wc_update_890_update_paypal_standard_load_eligibility() {
|
||||
$paypal->update_option( '_should_load', wc_bool_to_string( false ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the woocommerce_history_of_autoinstalled_plugins option if it doesn't exist
|
||||
* as a copy of woocommerce_autoinstalled_plugins if it exists.
|
||||
*/
|
||||
function wc_update_891_create_plugin_autoinstall_history_option() {
|
||||
$autoinstalled_plugins_history_info = get_site_option( 'woocommerce_history_of_autoinstalled_plugins' );
|
||||
if ( false === $autoinstalled_plugins_history_info ) {
|
||||
$autoinstalled_plugins_info = get_site_option( 'woocommerce_autoinstalled_plugins' );
|
||||
if ( false !== $autoinstalled_plugins_info ) {
|
||||
update_site_option( 'woocommerce_history_of_autoinstalled_plugins', $autoinstalled_plugins_info );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user