allow Category objects for empty categories
authorDaniel Kinzler <daniel@users.mediawiki.org>
Tue, 1 Jul 2008 20:49:23 +0000 (20:49 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Tue, 1 Jul 2008 20:49:23 +0000 (20:49 +0000)
includes/Category.php

index 4386491..45d2afa 100644 (file)
@@ -46,7 +46,18 @@ class Category {
                );
                if( !$row ) {
                        # Okay, there were no contents.  Nothing to initialize.
-                       return false;
+                       if ( $this->mTitle ) {
+                               # If there is a title object but no record in the category table, treat this as an empty category
+                               $this->mID      = false;
+                               $this->mName    = $this->mTitle->getDBKey();
+                               $this->mPages   = 0;
+                               $this->mSubcats = 0;
+                               $this->mFiles   = 0;
+
+                               return true;
+                       } else {
+                               return false; # Fail
+                       }
                }
                $this->mID      = $row->cat_id;
                $this->mName    = $row->cat_title;