(bug 26729) Categories that do not have a page, and have no members,
authorBrian Wolff <bawolff@users.mediawiki.org>
Sat, 15 Jan 2011 21:59:13 +0000 (21:59 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Sat, 15 Jan 2011 21:59:13 +0000 (21:59 +0000)
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.

RELEASE-NOTES
includes/CategoryPage.php

index 67aee9b..10b7495 100644 (file)
@@ -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
index 05bc6f3..cb469d2 100644 (file)
@@ -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() {