From e34a925007e2714492b9cf3eae61b0aba4d7ec1d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 16 Apr 2008 21:07:39 +0000 Subject: [PATCH] * Move affectedRows count up * Shouldn't need to pass db object here * Some code style tweaks --- includes/Article.php | 2 +- includes/Block.php | 5 ++--- includes/LogPage.php | 3 ++- includes/SpecialBlockip.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index af347d7100..73e8ccfba7 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2318,7 +2318,7 @@ class Article { # Now that it's safely backed up, delete it $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__); - $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy + $ok = ( $dbw->affectedRows() != 0 ); // getArticleId() uses slave, could be laggy if( !$ok ) { $dbw->rollback(); return false; diff --git a/includes/Block.php b/includes/Block.php index 9a7938946f..958580471d 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -358,13 +358,12 @@ class Block /** * Insert a block into the block table. - * @param Database $dbw, optional * @return Whether or not the insertion was successful. */ - function insert( $dbw = NULL) + function insert() { wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" ); - $dbw = $dbw ? $dbw : wfGetDB( DB_MASTER ); + $dbw = wfGetDB( DB_MASTER ); # Unset ipb_anon_only for user blocks, makes no sense if ( $this->mUser ) { diff --git a/includes/LogPage.php b/includes/LogPage.php index 041d05ce5e..34c935d99c 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -75,6 +75,7 @@ class LogPage { $dbw->insert( 'logging', $data, $fname ); $newId = $dbw->insertId(); + $ok = ($dbw->affectedRows() != 0); # And update recentchanges if( $this->updateRecentChanges ) { # Don't add private logs to RC! @@ -85,7 +86,7 @@ class LogPage { $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); } } - return ($dbw->affectedRows() > 0); + return $ok; } public function getRcComment() { diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 83eb23c7f4..4127579575 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -352,7 +352,7 @@ class IPBlockForm { if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { $dbw = wfGetDB( DB_MASTER ); $dbw->begin(); - if ( !$block->insert( $dbw ) ) { + if ( !$block->insert() ) { $dbw->rollback(); // this could be commit as well; zero rows either way return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress)); } -- 2.20.1