Only store currently-existing categories in the categories table
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 13 Jul 2016 15:30:37 +0000 (11:30 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 18 Jul 2016 16:52:19 +0000 (12:52 -0400)
commit47e2ef34b0c3dbecfc80b84acad9d2bb0baac1e2
treec5798eebbc7b3ffac86f678950da350021a89e2d
parent99b84272c21b84c4861ef41f1078a5cd38689782
Only store currently-existing categories in the categories table

A "currently-existing category" is defined as a category that either
contains any pages or has a description page. Thus:
* Category::initialize() now schedules an update to insert a row if the
  title exits but the row is missing.
* Category::refreshCounts() now removes the row if the title doesn't
  exist and the category is empty.
* WikiPage::onArticleCreate() loads the Category object, to trigger
  bullet #1.
* WikiPage::updateCategoryCounts() refreshes the counts if it results in
  the row showing 0 pages, to trigger bullet #2.
* LinksDeletionUpdate refreshes the counts if the row shows 0 pages, to
  trigger bullet #2.

A maintenance script is provided to update the category table for this
new definition.

Bug: T28411
Bug: T50824
Change-Id: I0f0adf124c181ae5d3c7c95b3b5fb275a725794c
autoload.php
includes/Category.php
includes/deferred/LinksDeletionUpdate.php
includes/installer/DatabaseUpdater.php
includes/page/WikiPage.php
maintenance/cleanupEmptyCategories.php [new file with mode: 0644]
maintenance/mssql/tables.sql
maintenance/tables.sql