@@ -200,6 +200,15 @@ public function get_tools() {
200
200
),
201
201
),
202
202
);
203
+ if ( method_exists ( 'WC_Install ' , 'verify_base_tables ' ) ) {
204
+ $ tools ['verify_db_tables ' ] = array (
205
+ 'name ' => __ ( 'Verify base database tables ' , 'woocommerce-rest-api ' ),
206
+ 'button ' => __ ( 'Verify database ' , 'woocommerce-rest-api ' ),
207
+ 'desc ' => sprintf (
208
+ __ ( 'Verify if all base database tables are present. ' , 'woocommerce-rest-api ' )
209
+ ),
210
+ );
211
+ }
203
212
204
213
// Jetpack does the image resizing heavy lifting so you don't have to.
205
214
if ( ( class_exists ( 'Jetpack ' ) && Jetpack::is_module_active ( 'photon ' ) ) || ! apply_filters ( 'woocommerce_background_image_regeneration ' , true ) ) {
@@ -459,7 +468,7 @@ public function execute_tool( $tool ) {
459
468
$ wpdb ->prepare (
460
469
"DELETE FROM {$ wpdb ->prefix }woocommerce_downloadable_product_permissions
461
470
WHERE ( downloads_remaining != '' AND downloads_remaining = 0 ) OR ( access_expires IS NOT NULL AND access_expires < %s ) " ,
462
- date ( 'Y-m-d ' , current_time ( 'timestamp ' ) )
471
+ gmdate ( 'Y-m-d ' , current_time ( 'timestamp ' ) )
463
472
)
464
473
)
465
474
);
@@ -538,6 +547,23 @@ public function execute_tool( $tool ) {
538
547
$ message = __ ( 'Database upgrade routine has been scheduled to run in the background. ' , 'woocommerce-rest-api ' );
539
548
break ;
540
549
550
+ case 'verify_db_tables ' :
551
+ if ( ! method_exists ( 'WC_Install ' , 'verify_base_tables ' ) ) {
552
+ $ message = __ ( 'You need WooCommerce 4.2 or newer to run this tool. ' , 'woocommerce-rest-api ' );
553
+ $ ran = false ;
554
+ break ;
555
+ }
556
+ // Try to manually create table again.
557
+ $ missing_tables = WC_Install::verify_base_tables ( true , true );
558
+ if ( 0 === count ( $ missing_tables ) ) {
559
+ $ message = __ ( 'Database verified successfully. ' , 'woocommerce-rest-api ' );
560
+ } else {
561
+ $ message = __ ( 'Verifying database... One or more tables are still missing: ' , 'woocommerce-rest-api ' );
562
+ $ message .= implode ( ', ' , $ missing_tables );
563
+ $ ran = false ;
564
+ }
565
+ break ;
566
+
541
567
default :
542
568
$ tools = $ this ->get_tools ();
543
569
if ( isset ( $ tools [ $ tool ]['callback ' ] ) ) {
0 commit comments