API: Change acprop description to allow for future expansion
[lhc/web/wiklou.git] / includes / Article.php
index 33e21ec..26b6494 100644 (file)
@@ -1518,7 +1518,7 @@ class Article {
                # Check patrol config options
 
                if ( !($wgUseNPPatrol || $wgUseRCPatrol)) {
-                       $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
+                       $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
                        return;         
                }
 
@@ -1527,7 +1527,7 @@ class Article {
                $rc = $rcid ? RecentChange::newFromId($rcid) : null;
                if ( is_null ( $rc ) )
                {
-                       $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
+                       $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
                        return;
                }
 
@@ -1535,7 +1535,7 @@ class Article {
                        // Only new pages can be patrolled if the general patrolling is off....???
                        // @fixme -- is this necessary? Shouldn't we only bother controlling the
                        // front end here?
-                       $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
+                       $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
                        return;
                }
                
@@ -2266,7 +2266,7 @@ class Article {
                foreach( $res as $row ) {
                        $cats []= $row->cl_to;
                }
-               $this->updateCategoryCounts( array(), $cats, $dbw );
+               $this->updateCategoryCounts( array(), $cats );
 
                # Now that it's safely backed up, delete it
                $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__);
@@ -3354,14 +3354,11 @@ class Article {
         *
         * @param $added array   The names of categories that were added
         * @param $deleted array The names of categories that were deleted
-        * @param $dbw Database  Optional database connection to use
         * @return null
         */
-       public function updateCategoryCounts( $added, $deleted, $dbw = null ) {
+       public function updateCategoryCounts( $added, $deleted ) {
                $ns = $this->mTitle->getNamespace();
-               if( !$dbw ) {
-                       $dbw = wfGetDB( DB_MASTER );
-               }
+               $dbw = wfGetDB( DB_MASTER );
 
                # First make sure the rows exist.  If one of the "deleted" ones didn't
                # exist, we might legitimately not create it, but it's simpler to just
@@ -3370,33 +3367,41 @@ class Article {
                #
                # Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE.
                $insertCats = array_merge( $added, $deleted );
+               if( !$insertCats ) {
+                       # Okay, nothing to do
+                       return;
+               }
                $insertRows = array();
                foreach( $insertCats as $cat ) {
-                       $insertRows []= array( 'cat_title' => $cat );
+                       $insertRows[] = array( 'cat_title' => $cat );
                }
                $dbw->insert( 'category', $insertRows, __METHOD__, 'IGNORE' );
 
                $addFields    = array( 'cat_pages = cat_pages + 1' );
                $removeFields = array( 'cat_pages = cat_pages - 1' );
                if( $ns == NS_CATEGORY ) {
-                       $addFields    []= 'cat_subcats = cat_subcats + 1';
-                       $removeFields []= 'cat_subcats = cat_subcats - 1';
+                       $addFields[]    = 'cat_subcats = cat_subcats + 1';
+                       $removeFields[] = 'cat_subcats = cat_subcats - 1';
                } elseif( $ns == NS_IMAGE ) {
-                       $addFields    []= 'cat_files = cat_files + 1';
-                       $removeFields []= 'cat_files = cat_files - 1';
+                       $addFields[]    = 'cat_files = cat_files + 1';
+                       $removeFields[] = 'cat_files = cat_files - 1';
                }
 
-               $dbw->update(
-                       'category',
-                       $addFields,
-                       array( 'cat_title' => $added ),
-                       __METHOD__
-               );
-               $dbw->update(
-                       'category',
-                       $removeFields,
-                       array( 'cat_title' => $deleted ),
-                       __METHOD__
-               );
+               if ( $added ) {
+                       $dbw->update(
+                               'category',
+                               $addFields,
+                               array( 'cat_title' => $added ),
+                               __METHOD__
+                       );
+               }
+               if ( $deleted ) {
+                       $dbw->update(
+                               'category',
+                               $removeFields,
+                               array( 'cat_title' => $deleted ),
+                               __METHOD__
+                       );
+               }
        }
 }