Fix "you are blocked" message for users who were blocked by zero-ID user.
[lhc/web/wiklou.git] / includes / Category.php
index 78567ad..e0a3563 100644 (file)
@@ -26,7 +26,7 @@ class Category {
         */
        protected function initialize() {
                if ( $this->mName === null && $this->mTitle ) 
-                       $this->mName = $title->getDBKey();
+                       $this->mName = $title->getDBkey();
 
                if( $this->mName === null && $this->mID === null ) {
                        throw new MWException( __METHOD__.' has both names and IDs null' );
@@ -41,8 +41,7 @@ class Category {
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow(
                        'category',
-                       array( 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats',
-                               'cat_files' ),
+                       array( 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ),
                        $where,
                        __METHOD__
                );
@@ -51,7 +50,7 @@ class Category {
                        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->mName    = $this->mTitle->getDBkey();
                                $this->mPages   = 0;
                                $this->mSubcats = 0;
                                $this->mFiles   = 0;
@@ -70,8 +69,7 @@ class Category {
                # (bug 13683) If the count is negative, then 1) it's obviously wrong
                # and should not be kept, and 2) we *probably* don't have to scan many
                # rows to obtain the correct figure, so let's risk a one-time recount.
-               if( $this->mPages < 0 || $this->mSubcats < 0 ||
-               $this->mFiles < 0 ) {
+               if( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) {
                        $this->refreshCounts();
                }
 
@@ -93,7 +91,7 @@ class Category {
                }
 
                $cat->mTitle = $title;
-               $cat->mName = $title->getDBKey();
+               $cat->mName = $title->getDBkey();
 
                return $cat;
        }
@@ -108,7 +106,7 @@ class Category {
                $cat = new self();
 
                $cat->mTitle = $title;
-               $cat->mName = $title->getDBKey();
+               $cat->mName = $title->getDBkey();
 
                return $cat;
        }
@@ -151,7 +149,7 @@ class Category {
                                # but we can't know that here...
                                return false;
                        } else {
-                               $cat->mName = $title->getDBKey(); # if we have a title object, fetch the category name from there
+                               $cat->mName = $title->getDBkey(); # if we have a title object, fetch the category name from there
                        }
 
                        $cat->mID =   false;
@@ -248,9 +246,11 @@ class Category {
                } else {
                        # Let's be sure that the row exists in the table.  We don't need to
                        # do this if we got the row from the table in initialization!
+                       $seqVal = $dbw->nextSequenceValue( 'category_cat_id_seq' );
                        $dbw->insert(
                                'category',
-                               array( 'cat_title' => $this->mName ),
+                               array(  'cat_id' => $seqVal, 
+                                                               'cat_title' => $this->mName ),
                                __METHOD__,
                                'IGNORE'
                        );