Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit e162cbe

Browse files
committed
fix merge conflits
2 parents 8047840 + bd45d70 commit e162cbe

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"classmap": [
3838
"src/Controllers/Version1",
3939
"src/Controllers/Version2",
40-
"src/Controllers/Version3"
40+
"src/Controllers/Version3",
41+
"src/Controllers/Version4"
4142
],
4243
"psr-4": {
4344
"Automattic\\WooCommerce\\RestApi\\": "src"

src/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ public function get_tools() {
209209
),
210210
),
211211
);
212+
if ( method_exists( 'WC_Install', 'verify_base_tables' ) ) {
213+
$tools['verify_db_tables'] = array(
214+
'name' => __( 'Verify base database tables', 'woocommerce-rest-api' ),
215+
'button' => __( 'Verify database', 'woocommerce-rest-api' ),
216+
'desc' => sprintf(
217+
__( 'Verify if all base database tables are present.', 'woocommerce-rest-api' )
218+
),
219+
);
220+
}
212221

213222
// Jetpack does the image resizing heavy lifting so you don't have to.
214223
if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', true ) ) {
@@ -472,7 +481,7 @@ public function execute_tool( $tool ) {
472481
$wpdb->prepare(
473482
"DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions
474483
WHERE ( downloads_remaining != '' AND downloads_remaining = 0 ) OR ( access_expires IS NOT NULL AND access_expires < %s )",
475-
date( 'Y-m-d', current_time( 'timestamp' ) )
484+
gmdate( 'Y-m-d', current_time( 'timestamp' ) )
476485
)
477486
)
478487
);
@@ -557,6 +566,20 @@ public function execute_tool( $tool ) {
557566
$message = __( 'Template cache cleared.', 'woocommerce-rest-api' );
558567
} else {
559568
$message = __( 'The active version of WooCommerce does not support template cache clearing.', 'woocommerce-rest-api' );
569+
case 'verify_db_tables':
570+
if ( ! method_exists( 'WC_Install', 'verify_base_tables' ) ) {
571+
$message = __( 'You need WooCommerce 4.2 or newer to run this tool.', 'woocommerce-rest-api' );
572+
$ran = false;
573+
break;
574+
}
575+
// Try to manually create table again.
576+
$missing_tables = WC_Install::verify_base_tables( true, true );
577+
if ( 0 === count( $missing_tables ) ) {
578+
$message = __( 'Database verified successfully.', 'woocommerce-rest-api' );
579+
} else {
580+
$message = __( 'Verifying database... One or more tables are still missing: ', 'woocommerce-rest-api' );
581+
$message .= implode( ', ', $missing_tables );
582+
$ran = false;
560583
}
561584
break;
562585

0 commit comments

Comments
 (0)