Merge "Improve default behavior for HTMLForm::canDisplayErrors"
[lhc/web/wiklou.git] / includes / deferred / DeferredUpdates.php
index 1552777..ee14e1a 100644 (file)
@@ -61,16 +61,19 @@ 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()
         *
         * @param callable $callable
         * @param integer $type DeferredUpdates constant (PRESEND or POSTSEND) (since 1.27)
+        * @param IDatabase|null $dbw Abort if this DB is rolled back [optional] (since 1.28)
         */
-       public static function addCallableUpdate( $callable, $type = self::POSTSEND ) {
-               self::addUpdate( new MWCallableUpdate( $callable ), $type );
+       public static function addCallableUpdate(
+               $callable, $type = self::POSTSEND, IDatabase $dbw = null
+       ) {
+               self::addUpdate( new MWCallableUpdate( $callable, wfGetCaller(), $dbw ), $type );
        }
 
        /**
@@ -143,7 +146,11 @@ class DeferredUpdates {
                                } else {
                                        $otherUpdates[] = $update;
                                }
-                               $stats->increment( 'deferred_updates.' . $method . '.' . get_class( $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