+ /**
+ * @param Title $title
+ */
+ private function refreshCategoryIfEmpty( Title $title ) {
+ $dbw = $this->getDB();
+
+ $row = $dbw->selectRow(
+ 'category',
+ [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ],
+ [ 'cat_title' => $title->getDBkey(), 'cat_pages <= 100' ],
+ __METHOD__
+ );
+
+ if ( !$row ) {
+ return; // nothing to delete
+ }
+
+ $cat = Category::newFromRow( $row, $title );
+ $hasLink = $dbw->selectField(
+ 'categorylinks',
+ '1',
+ [ 'cl_to' => $title->getDBkey() ],
+ __METHOD__
+ );
+ if ( !$hasLink ) {
+ $cat->refreshCounts(); // delete the category table entry
+ }
+ }
+