44 *
55 * @package WC_Calypso_Bridge/Classes
66 * @since 1.0.0
7- * @version 2.2.15
7+ * @version x.x.x
88 */
99
1010use Automattic \WooCommerce \Admin \WCAdminHelper ;
@@ -223,10 +223,10 @@ public function woocommerce_create_pages_callback() {
223223
224224 $ this ->write_to_log ( $ operation , 'INITIALIZED ' );
225225
226- // Set the operation as completed if the store is active for more than 10 minutes.
227- if ( WCAdminHelper::is_wc_admin_active_for ( 10 * MINUTE_IN_SECONDS ) ) {
226+ // Set the operation as completed if the store is active for more than 60 minutes.
227+ if ( WCAdminHelper::is_wc_admin_active_for ( 60 * MINUTE_IN_SECONDS ) ) {
228228 update_option ( $ this ->option_prefix . $ operation , 'completed ' , 'no ' );
229- $ this ->write_to_log ( $ operation , 'completed (10 minutes) ' );
229+ $ this ->write_to_log ( $ operation , 'completed (60 minutes) ' );
230230
231231 return ;
232232 }
@@ -308,6 +308,13 @@ public function woocommerce_create_pages_callback() {
308308 } else {
309309 $ this ->write_to_log ( $ operation , 'failed to delete option woocommerce_ ' . $ key . '_page_id : ' . $ value );
310310 }
311+
312+ $ result_cache = wp_cache_delete ( "woocommerce_ {$ key }_page_id " , 'options ' );
313+ if ( $ result_cache ) {
314+ $ this ->write_to_log ( $ operation , 'deleted cache for option woocommerce_ ' . $ key . '_page_id : ' . $ value );
315+ } else {
316+ $ this ->write_to_log ( $ operation , 'failed to delete cache for option woocommerce_ ' . $ key . '_page_id : ' . $ value );
317+ }
311318 }
312319
313320 /*
@@ -330,6 +337,12 @@ public function woocommerce_create_pages_callback() {
330337 wp_cache_flush ();
331338 usleep ( 500000 );
332339
340+ $ this ->write_to_log ( $ operation , 'GETTING WOOCOMMERCE PAGE OPTIONS AFTER DELETION ' );
341+ foreach ( $ woocommerce_pages as $ key => $ page_slug ) {
342+ $ value = get_option ( "woocommerce_ {$ key }_page_id " );
343+ $ this ->write_to_log ( $ operation , 'getting option woocommerce_ ' . $ key . '_page_id : ' . $ value );
344+ }
345+
333346 // Delete the following note, so it can be recreated with the correct refund page ID.
334347 if ( class_exists ( 'Automattic\WooCommerce\Admin\Notes\Notes ' ) ) {
335348 Automattic \WooCommerce \Admin \Notes \Notes::delete_notes_with_name ( 'wc-refund-returns-page ' );
@@ -689,7 +702,7 @@ private function write_to_log( $operation, $message ) {
689702
690703 /**
691704 * Maybe delete page by slug.
692- * If the page is older than 10 minutes, it will be ignored.
705+ * If the page is older than 60 minutes, it will be ignored.
693706 *
694707 * @since 2.2.15
695708 *
@@ -714,13 +727,14 @@ private function maybe_delete_page_by_slug( $slug, $operation ) {
714727 $ current_time_gmt_ts = current_time ( 'U ' , true );
715728 $ diff_ts = $ current_time_gmt_ts - $ page_gmt_ts ;
716729
717- if ( $ diff_ts > 10 * MINUTE_IN_SECONDS ) {
718- $ this ->write_to_log ( $ operation , 'ignored page deletion ' . $ slug . ' diff: ' . $ diff_ts / 60 . ' minutes (older than 10 minutes) ' );
730+ if ( $ diff_ts > 60 * MINUTE_IN_SECONDS ) {
731+ $ this ->write_to_log ( $ operation , 'ignored page deletion ' . $ slug . ' diff: ' . $ diff_ts / 60 . ' minutes (older than 60 minutes) ' );
719732
720733 return ;
721734 }
722735
723736 $ result = wp_delete_post ( $ page ['ID ' ], true );
737+ clean_post_cache ( $ page ['ID ' ] );
724738 if ( $ result ) {
725739 $ this ->write_to_log ( $ operation , 'deleted page ' . $ slug );
726740 } else {
0 commit comments