Revert "Monitor only memory limit while running the data migration"
This reverts commit 923eeb2e43
.
This commit is contained in:
parent
ad31742ba1
commit
ee6e0a345e
|
@ -137,7 +137,7 @@ class WC_Background_Updater extends WC_Background_Process {
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_memory_exceeded() {
|
||||
return $this->memory_exceeded();
|
||||
public function is_batch_limit_exceeded() {
|
||||
return $this->batch_limit_exceeded();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1893,7 +1893,7 @@ function wc_update_350_order_customer_id( $updater = false ) {
|
|||
|
||||
$wpdb->update( $wpdb->posts, array( 'post_author' => 0 ), array( 'post_type' => 'shop_order_refund' ) );
|
||||
} else {
|
||||
// If running the update from the wp-admin, copy data in batches being careful not to use more memory than allowed.
|
||||
// If running the update from the wp-admin, copy data in batches being careful not to use more memory than allowed and respecting PHP time limit.
|
||||
$admin_orders_sql = '';
|
||||
|
||||
// Get the list of orders that we don't want to change as they belong to user ID 1.
|
||||
|
@ -1941,9 +1941,9 @@ function wc_update_350_order_customer_id( $updater = false ) {
|
|||
|
||||
// Update post_author for a batch of orders.
|
||||
foreach ( $orders_meta_data as $order_meta ) {
|
||||
// Stop update execution and re-enqueue it if near memory limit.
|
||||
if ( $updater instanceof WC_Background_Updater && $updater->is_memory_exceeded() ) {
|
||||
return true;
|
||||
// Stop update execution and re-enqueue it if near memory and timeout limits.
|
||||
if ( $updater instanceof WC_Background_Updater && $updater->is_batch_limit_exceeded() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$wpdb->update( $wpdb->posts, array( 'post_author' => $order_meta->customer_id ), array( 'ID' => $order_meta->post_id ) );
|
||||
|
@ -1952,9 +1952,9 @@ function wc_update_350_order_customer_id( $updater = false ) {
|
|||
|
||||
// Set post_author to 0 instead of 1 on all shop_order_refunds.
|
||||
while ( true ) {
|
||||
// Stop update execution and re-enqueue it if near memory limit.
|
||||
if ( $updater instanceof WC_Background_Updater && $updater->is_memory_exceeded() ) {
|
||||
return true;
|
||||
// Stop update execution and re-enqueue it if near memory and timeout limits.
|
||||
if ( $updater instanceof WC_Background_Updater && $updater->is_batch_limit_exceeded() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$updated_rows = $wpdb->query( "UPDATE {$wpdb->posts} SET post_author = 0 WHERE post_type = 'shop_order_refund' LIMIT 1000" );
|
||||
|
|
Loading…
Reference in New Issue