# Check patrol config options
if ( !($wgUseNPPatrol || $wgUseRCPatrol)) {
- $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
+ $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
return;
}
$rc = $rcid ? RecentChange::newFromId($rcid) : null;
if ( is_null ( $rc ) )
{
- $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
+ $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
return;
}
// 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;
}
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__);
*
* @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
#
# 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__
+ );
+ }
}
}