Page MenuHomePhabricator

Wrong subcategory counts in Commons
Closed, DuplicatePublic


This is probably explained best with an example. In the Commons category, the first subcategory "17th-century portrait paintings of men, artist, location and year missing‎" is displayed as containing 2 subcategories, with an activated arrow button for the subcategory drop-down list. But this subcategory doesn't actually contain any subcategories.

There are various similar examples other categories, such as, e.g., 1 Chome Higashikaiganminami in Chigasaki from panoramio‎

This problem doesn't seem to occur in Wikipedia.

Event Timeline

I've fixed those two specific cases by running populateCategories.php...

AFAIK, drift is known to occur, or has in the past. This may be fixed now though

I don't know if we need to schedule a one off run (for all wikis) to update each count, or if we need to be doing it as a more frequent maintenance script run

Thanks. There are plenty of other examples in Commons, such as other subcategories in and many in It seems to effect only categories that have names starting with numbers, but not every such category.

I just noticed this for that has no subcats but is listed as having "3C" at and other parent cats of it. That's another "starting with a number" cat, part of the pattern Ghouston mentioned.

@Peachey88, is there a reason you removed MediaWiki-Categories from this category-related task?

This needs no code changes in category code in MediaWiki core. Hence it should not be tagged as MediaWiki-Categories.

Base added subscribers: Base, Ahonc, Kharkivian.

Description of the duplicate I filed:

A user has pointed out a case of Category:10,_Bratkovsky_Street,_Lutsk which is categorised into Category:Non-empty_category_redirects by Template:Category_redirect . Is not a case of recent move.

It gets there because PAGESINCAT for the category returns 2, while there are actually 0 members in it. This number is also visible at the top level category level for it, showing 2 categories in it but not the actual categories.

So I ran the following at Quarry

use commonswiki_p;
select *
from categorylinks
where cl_to = '10,_Bratkovsky_Street,_Lutsk';

select * from category
where cat_title = '10,_Bratkovsky_Street,_Lutsk'

and I see that it has information about 2 categories and pages in, while no categorylinks are recorded.

The user claims that there are many other cases like this and running

select *
from category
where cat_pages > 0
and 0 = (
  select count(*) from categorylinks where cl_to = cat_title
limit 100

confirms this. says

If the information in this table is incorrect, run the maintenance scripts populateCategory.php and/or cleanupEmptyCategories.php, if necessary with the --force option.

I assume that is what has to be done.

This needs no code changes in category code in MediaWiki core. Hence it should not be tagged as MediaWiki-Categories.

I am not a MW developer but if such situation happens it does sound as a possible bug in the code. Though it should probably be covered by another ticket.

Taylor added a subscriber: Taylor.

Closing this in favor of T85696 because the very same problem occurs on wikipedia, wiktionary and other wikis.