resourceloader: spin base module code out as a proper module
[lhc/web/wiklou.git] / includes / Category.php
index fb5916b..41ecc65 100644 (file)
@@ -335,6 +335,16 @@ class Category {
 
                $dbw->startAtomic( __METHOD__ );
 
+               // Lock the `category` row before locking `categorylinks` rows to try
+               // to avoid deadlocks with LinksDeletionUpdate (T195397)
+               $dbw->selectField(
+                       'category',
+                       1,
+                       [ 'cat_title' => $this->mName ],
+                       __METHOD__,
+                       [ 'FOR UPDATE' ]
+               );
+
                // Lock all the `categorylinks` records and gaps for this category;
                // this is a separate query due to postgres/oracle limitations
                $dbw->selectRowCount(