Merge "MessagesGom_deva: Correct syntax in namespace alias"
[lhc/web/wiklou.git] / includes / deferred / DeferredUpdates.php
index 249b207..9768838 100644 (file)
@@ -61,7 +61,7 @@ class DeferredUpdates {
        }
 
        /**
-        * Add a callable update.  In a lot of cases, we just need a callback/closure,
+        * Add a callable update. In a lot of cases, we just need a callback/closure,
         * defining a new DeferrableUpdate object is not necessary
         *
         * @see MWCallableUpdate::__construct()
@@ -70,7 +70,7 @@ class DeferredUpdates {
         * @param integer $type DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27)
         */
        public static function addCallableUpdate( $callable, $type = self::POSTSEND ) {
-               self::addUpdate( new MWCallableUpdate( $callable ), $type );
+               self::addUpdate( new MWCallableUpdate( $callable, wfGetCaller() ), $type );
        }
 
        /**
@@ -126,8 +126,10 @@ class DeferredUpdates {
        }
 
        public static function execute( array &$queue, $mode ) {
-               $updates = $queue; // snapshot of queue
+               $stats = \MediaWiki\MediaWikiServices::getInstance()->getStatsdDataFactory();
+               $method = RequestContext::getMain()->getRequest()->getMethod();
 
+               $updates = $queue; // snapshot of queue
                // Keep doing rounds of updates until none get enqueued
                while ( count( $updates ) ) {
                        $queue = []; // clear the queue
@@ -141,10 +143,20 @@ class DeferredUpdates {
                                } else {
                                        $otherUpdates[] = $update;
                                }
+
+                               $name = $update instanceof DeferrableCallback
+                                       ? get_class( $update ) . '-' . $update->getOrigin()
+                                       : get_class( $update );
+                               $stats->increment( 'deferred_updates.' . $method . '.' . $name );
                        }
 
                        // Delegate DataUpdate execution to the DataUpdate class
-                       DataUpdate::runUpdates( $dataUpdates, $mode );
+                       try {
+                               DataUpdate::runUpdates( $dataUpdates, $mode );
+                       } catch ( Exception $e ) {
+                               // Let the other updates occur if these had to rollback
+                               MWExceptionHandler::logException( $e );
+                       }
                        // Execute the non-DataUpdate tasks
                        foreach ( $otherUpdates as $update ) {
                                try {