Merge pull request #32968 from woocommerce/fix/download_dir_table_key
Fix/download dir table key
This commit is contained in:
commit
82e6e31903
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Specify a maximum index size for the URL column in the Download Directories table.
|
|
@ -206,6 +206,9 @@ class WC_Install {
|
|||
'6.5.0' => array(
|
||||
'wc_update_650_approved_download_directories',
|
||||
),
|
||||
'6.5.1' => array(
|
||||
'wc_update_651_approved_download_directories',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -1232,7 +1235,7 @@ CREATE TABLE {$wpdb->prefix}wc_product_download_directories (
|
|||
url varchar(256) NOT NULL,
|
||||
enabled TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (url_id),
|
||||
KEY `url` (`url`)
|
||||
KEY url (url($max_index_length))
|
||||
) $collate;
|
||||
CREATE TABLE {$wpdb->prefix}wc_order_stats (
|
||||
order_id bigint(20) unsigned NOT NULL,
|
||||
|
|
|
@ -2404,3 +2404,29 @@ function wc_update_650_approved_download_directories() {
|
|||
$directory_sync->init_hooks();
|
||||
$directory_sync->init_feature( true, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* In some cases, the approved download directories table may not have been successfully created during the update to
|
||||
* 6.5.0. If this was the case we will need to re-initialize the feature.
|
||||
*/
|
||||
function wc_update_651_approved_download_directories() {
|
||||
global $wpdb;
|
||||
|
||||
$download_directories = wc_get_container()->get( Download_Directories::class );
|
||||
$directory_sync = wc_get_container()->get( Download_Directories_Sync::class );
|
||||
|
||||
// Check if at least 1 row exists, without scanning the entire table.
|
||||
$is_populated = (bool) $wpdb->get_var(
|
||||
'SELECT 1 FROM ' . $download_directories->get_table() . ' LIMIT 1'
|
||||
);
|
||||
|
||||
// If the table contains rules (or does not yet, but a sync is in-progress) we should do nothing else at this point.
|
||||
if ( $is_populated || $directory_sync->in_progress() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, it seems reasonable to assume that the feature was not initialized as expected during the update to
|
||||
// 6.5.0. Let's give that another try.
|
||||
$directory_sync->init_hooks();
|
||||
$directory_sync->init_feature( true, false );
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class Synchronize {
|
|||
$this->start();
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
wc_get_logger()->log( 'warning', __( 'It was not possible to synchronize download directories following the update to 6.4.0.', 'woocommerce' ) );
|
||||
wc_get_logger()->log( 'warning', __( 'It was not possible to synchronize download directories following the most recent update.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
$this->register->set_mode(
|
||||
|
|
|
@ -125,15 +125,16 @@ class WC_Admin_Tests_Install extends WP_UnitTestCase {
|
|||
public function db_update_version_provider() {
|
||||
return array(
|
||||
// [DB Update version string, # of expected pending jobs]
|
||||
array( '3.9.0', 33 ),
|
||||
array( '4.0.0', 26 ),
|
||||
array( '4.4.0', 22 ),
|
||||
array( '4.5.0', 20 ),
|
||||
array( '5.0.0', 16 ),
|
||||
array( '5.6.0', 14 ),
|
||||
array( '6.0.0', 7 ),
|
||||
array( '6.3.0', 4 ),
|
||||
array( '6.4.0', 1 ),
|
||||
array( '3.9.0', 34 ),
|
||||
array( '4.0.0', 27 ),
|
||||
array( '4.4.0', 23 ),
|
||||
array( '4.5.0', 21 ),
|
||||
array( '5.0.0', 17 ),
|
||||
array( '5.6.0', 15 ),
|
||||
array( '6.0.0', 8 ),
|
||||
array( '6.3.0', 5 ),
|
||||
array( '6.4.0', 2 ),
|
||||
array( '6.5.0', 1 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue