Merge "Handle missing namespace prefix in XML dumps more gracefully"
[lhc/web/wiklou.git] / includes / deferred / DeferredUpdates.php
index 1ba6c1f..0a9755d 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\LBFactory;
+use Wikimedia\Rdbms\LoadBalancer;
 
 /**
  * Class for managing the deferred updates
@@ -334,6 +336,21 @@ class DeferredUpdates {
                return count( self::$preSendUpdates ) + count( self::$postSendUpdates );
        }
 
+       /**
+        * @param integer $stage DeferredUpdates constant (PRESEND, POSTSEND, or ALL)
+        * @since 1.29
+        */
+       public static function getPendingUpdates( $stage = self::ALL ) {
+               $updates = [];
+               if ( $stage === self::ALL || $stage === self::PRESEND ) {
+                       $updates = array_merge( $updates, self::$preSendUpdates );
+               }
+               if ( $stage === self::ALL || $stage === self::POSTSEND ) {
+                       $updates = array_merge( $updates, self::$postSendUpdates );
+               }
+               return $updates;
+       }
+
        /**
         * Clear all pending updates without performing them. Generally, you don't
         * want or need to call this. Unit tests need it though.