* Move affectedRows count up
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 16 Apr 2008 21:07:39 +0000 (21:07 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 16 Apr 2008 21:07:39 +0000 (21:07 +0000)
* Shouldn't need to pass db object here
* Some code style tweaks

includes/Article.php
includes/Block.php
includes/LogPage.php
includes/SpecialBlockip.php

index af347d7..73e8ccf 100644 (file)
@@ -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;
index 9a79389..9585804 100644 (file)
@@ -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 ) {
index 041d05c..34c935d 100644 (file)
@@ -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() {
index 83eb23c..4127579 100644 (file)
@@ -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));
                        }