X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdeferred%2FDeferredUpdates.php;h=249b207d6db39ee7e4f0be4a1fbf9dd6affdaa8f;hb=92ce715a55ab6998f916cbe9792af9fdb7d27fd9;hp=adad908e3688b8e1ac27ae0fbd4abd1b0f85416c;hpb=764dc6ae51b301e25b0361d113990a01a1a44fa5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index adad908e36..249b207d6d 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -38,12 +38,9 @@ */ class DeferredUpdates { /** @var DeferrableUpdate[] Updates to be deferred until before request end */ - private static $preSendUpdates = array(); + private static $preSendUpdates = []; /** @var DeferrableUpdate[] Updates to be deferred until after request end */ - private static $postSendUpdates = array(); - - /** @var bool Defer updates fully even in CLI mode */ - private static $forceDeferral = false; + private static $postSendUpdates = []; const ALL = 0; // all updates const PRESEND = 1; // for updates that should run before flushing output buffer @@ -108,10 +105,6 @@ class DeferredUpdates { $queue[] = $update; } - if ( self::$forceDeferral ) { - return; // do not run - } - // CLI scripts may forget to periodically flush these updates, // so try to handle that rather than OOMing and losing them entirely. // Try to run the updates as soon as there is no current wiki transaction. @@ -137,11 +130,11 @@ class DeferredUpdates { // Keep doing rounds of updates until none get enqueued while ( count( $updates ) ) { - $queue = array(); // clear the queue + $queue = []; // clear the queue /** @var DataUpdate[] $dataUpdates */ - $dataUpdates = array(); + $dataUpdates = []; /** @var DeferrableUpdate[] $otherUpdates */ - $otherUpdates = array(); + $otherUpdates = []; foreach ( $updates as $update ) { if ( $update instanceof DataUpdate ) { $dataUpdates[] = $update; @@ -156,7 +149,7 @@ class DeferredUpdates { foreach ( $otherUpdates as $update ) { try { $update->doUpdate(); - wfGetLBFactory()->commitMasterChanges(); + wfGetLBFactory()->commitMasterChanges( __METHOD__ ); } catch ( Exception $e ) { // We don't want exceptions thrown during deferred updates to // be reported to the user since the output is already sent @@ -165,7 +158,7 @@ class DeferredUpdates { } // Make sure incomplete transactions are not committed and end any // open atomic sections so that other DB updates have a chance to run - wfGetLBFactory()->rollbackMasterChanges(); + wfGetLBFactory()->rollbackMasterChanges( __METHOD__ ); } } @@ -178,16 +171,7 @@ class DeferredUpdates { * want or need to call this. Unit tests need it though. */ public static function clearPendingUpdates() { - self::$preSendUpdates = array(); - self::$postSendUpdates = array(); - } - - /** - * @note This method is intended for testing purposes - * @param bool $value Whether to *always* defer updates, even in CLI mode - * @since 1.27 - */ - public static function forceDeferral( $value ) { - self::$forceDeferral = $value; + self::$preSendUpdates = []; + self::$postSendUpdates = []; } }