From: Brian Wolff Date: Sat, 15 Jan 2011 21:59:13 +0000 (+0000) Subject: (bug 26729) Categories that do not have a page, and have no members, X-Git-Tag: 1.31.0-rc.0~32516 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=01ca30134da6f156ec804e5d933abedf4b18c36b (bug 26729) Categories that do not have a page, and have no members, should return 404 Previously, a category returned 404, only if it had no content page, had no members, and never had any members (aka there was no entry in the category table for it). As before, if you're editing the category page, its still considered a 200. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 67aee9b0ee..10b74958da 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -80,6 +80,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 10158) Do not mention allowing others to contact you when the feature is disabled ($wgEnableUserEmail=false) * (bug 26733) Wrap initial table creation in transaction +* (bug 26729) Category pages should return 404 if they do not exist and have no + members. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 05bc6f3d6d..cb469d2857 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -44,14 +44,23 @@ class CategoryPage extends Article { /** * Don't return a 404 for categories in use. + * In use defined as: either the actual page exists + * or the category currently has members. */ function hasViewableContent() { if ( parent::hasViewableContent() ) { return true; } else { $cat = Category::newFromTitle( $this->mTitle ); - return $cat->getId() != 0; + // If any of these are not 0, then has members + if ( $cat->getPageCount() + || $cat->getSubcatCount() + || $cat->getFileCount() + ) { + return true; + } } + return false; } function openShowCategory() {