Merge "Avoid 'message' in log context in AuthManager"
[lhc/web/wiklou.git] / includes / deferred / LinksUpdate.php
index 6124a71..8954304 100644 (file)
@@ -108,6 +108,8 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
         * @throws MWException
         */
        function __construct( Title $title, ParserOutput $parserOutput, $recursive = true ) {
+               parent::__construct();
+
                $this->mTitle = $title;
                $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
 
@@ -160,19 +162,24 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
         * @note: this is managed by DeferredUpdates::execute(). Do not run this in a transaction.
         */
        public function doUpdate() {
-               // Make sure all links update threads see the changes of each other.
-               // This handles the case when updates have to batched into several COMMITs.
-               $scopedLock = self::acquirePageLock( $this->getDB(), $this->mId );
+               if ( $this->ticket ) {
+                       // Make sure all links update threads see the changes of each other.
+                       // This handles the case when updates have to batched into several COMMITs.
+                       $scopedLock = self::acquirePageLock( $this->getDB(), $this->mId );
+               }
 
                Hooks::run( 'LinksUpdate', [ &$this ] );
                $this->doIncrementalUpdate();
 
-               // Commit and release the lock
+               // Commit and release the lock (if set)
                ScopedCallback::consume( $scopedLock );
                // Run post-commit hooks without DBO_TRX
-               $this->getDB()->onTransactionIdle( function() {
-                       Hooks::run( 'LinksUpdateComplete', [ &$this ] );
-               } );
+               $this->getDB()->onTransactionIdle(
+                       function () {
+                               Hooks::run( 'LinksUpdateComplete', [ &$this, $this->ticket ] );
+                       },
+                       __METHOD__
+               );
        }
 
        /**