Fix bogus field reference in Category::getCountMessage() callback
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 20 Apr 2017 03:43:56 +0000 (20:43 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 20 Apr 2017 04:25:37 +0000 (21:25 -0700)
Follows-up 922e68f739f143. (T162121)

Bug: T162941
Change-Id: I40623203e97f7155c2af171a37b1128a59415315

includes/Category.php
includes/CategoryViewer.php

index ece32ea..50ffeec 100644 (file)
@@ -321,6 +321,13 @@ class Category {
                }
 
                $dbw = wfGetDB( DB_MASTER );
+               # Avoid excess contention on the same category (T162121)
+               $name = __METHOD__ . ':' . md5( $this->mName );
+               $scopedLock = $dbw->getScopedLockAndFlush( $name, __METHOD__, 1 );
+               if ( !$scopedLock ) {
+                       return;
+               }
+
                $dbw->startAtomic( __METHOD__ );
 
                $cond1 = $dbw->conditional( [ 'page_namespace' => NS_CATEGORY ], 1, 'NULL' );
index 0205d70..7086a48 100644 (file)
@@ -740,16 +740,7 @@ class CategoryViewer extends ContextSource {
                        // to refresh the incorrect category table entry -- which should be
                        // quick due to the small number of entries.
                        $totalcnt = $rescnt;
-                       $category = $this->cat;
-                       DeferredUpdates::addCallableUpdate( function () use ( $category ) {
-                               # Avoid excess contention on the same category (T162121)
-                               $dbw = wfGetDB( DB_MASTER );
-                               $name = __METHOD__ . ':' . md5( $this->mName );
-                               $scopedLock = $dbw->getScopedLockAndFlush( $name, __METHOD__, 1 );
-                               if ( $scopedLock ) {
-                                       $category->refreshCounts();
-                               }
-                       } );
+                       DeferredUpdates::addCallableUpdate( [ $this->cat, 'refreshCounts' ] );
                } else {
                        // Case 3: hopeless.  Don't give a total count at all.
                        // Messages: category-subcat-count-limited, category-article-count-limited,