From b52a75d33ed72eb83b23e044dd8ec26bbc98c2dc Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 27 Apr 2008 23:45:31 +0000 Subject: [PATCH] Remove log debugging code, not needed anymore --- includes/Article.php | 11 ++++------- includes/LogPage.php | 7 ++----- includes/SpecialBlockip.php | 23 +++++++++-------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 59d86d88f9..18be4da422 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; @@ -2349,6 +2349,7 @@ class Article { array( 'rc_namespace' => $ns, 'rc_title' => $t, 'rc_type != '.RC_LOG ), __METHOD__ ); } + $dbw->commit(); # Clear caches Article::onArticleDelete( $this->mTitle ); @@ -2360,13 +2361,9 @@ class Article { # Log the deletion, if the page was suppressed, log it at Oversight instead $logtype = $suppress ? 'suppress' : 'delete'; $log = new LogPage( $logtype ); + # Make sure logging got through - $ok = $log->addEntry( 'delete', $this->mTitle, $reason, array() ); - if( !$ok ) { - $dbw->rollback(); - return false; - } - $dbw->commit(); + $log->addEntry( 'delete', $this->mTitle, $reason, array() ); return true; } diff --git a/includes/LogPage.php b/includes/LogPage.php index fe968452ba..66cb348350 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -73,9 +73,8 @@ class LogPage { $dbw->insert( 'logging', $data, $fname ); $newId = $dbw->insertId(); - $ok = ($dbw->affectedRows() > 0); # And update recentchanges - if( $ok && $this->updateRecentChanges ) { + if( $this->updateRecentChanges ) { # Don't add private logs to RC! if( !isset($wgLogRestrictions[$this->type]) || $wgLogRestrictions[$this->type]=='*' ) { $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); @@ -83,10 +82,8 @@ class LogPage { RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId ); } - } else { - wfDebug( "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" ); } - return $ok; + return true; } public function getRcComment() { diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 4127579575..61a2910fe3 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -349,14 +349,14 @@ class IPBlockForm { $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName, $this->BlockEmail); - if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); + if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) { + if ( !$block->insert() ) { - $dbw->rollback(); // this could be commit as well; zero rows either way return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress)); } + wfRunHooks('BlockIpComplete', array($block, $wgUser)); + # Prepare log parameters $logParams = array(); $logParams[] = $expirestr; @@ -365,19 +365,14 @@ class IPBlockForm { # Make log entry, if the name is hidden, put it in the oversight log $log_type = ($this->BlockHideName) ? 'suppress' : 'block'; $log = new LogPage( $log_type ); - $ok = $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $reasonstr, $logParams ); - # Make sure logging got through - if( !$ok ) { - $dbw->rollback(); - return array('databaseerror'); - } - $dbw->commit(); - wfRunHooks('BlockIpComplete', array($block, $wgUser)); + $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), + $reasonstr, $logParams ); + # Report to the user return array(); - } else { - return array('hookaborted'); } + else + return array('hookaborted'); } /** -- 2.20.1