6.5.1 update routine for approved download directories.
This commit is contained in:
parent
f994ba1839
commit
0d1da4e8bf
|
@ -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(
|
'6.5.0' => array(
|
||||||
'wc_update_650_approved_download_directories',
|
'wc_update_650_approved_download_directories',
|
||||||
),
|
),
|
||||||
|
'6.5.1' => array(
|
||||||
|
'wc_update_651_approved_download_directories',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2404,3 +2404,29 @@ function wc_update_650_approved_download_directories() {
|
||||||
$directory_sync->init_hooks();
|
$directory_sync->init_hooks();
|
||||||
$directory_sync->init_feature( true, false );
|
$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_col(
|
||||||
|
'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();
|
$this->start();
|
||||||
}
|
}
|
||||||
} catch ( Exception $e ) {
|
} 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(
|
$this->register->set_mode(
|
||||||
|
|
Loading…
Reference in New Issue