* Removed usage of error suppression operator in includes/db
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 4 Jul 2011 15:00:30 +0000 (15:00 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 4 Jul 2011 15:00:30 +0000 (15:00 +0000)
* Changed an usage of $_REQUEST to $wgRequest

includes/db/Database.php
includes/db/DatabaseError.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMysql.php
includes/db/DatabasePostgres.php

index 74fe86b..038332e 100644 (file)
@@ -1877,9 +1877,9 @@ abstract class DatabaseBase implements DatabaseType {
                # the correct table.
                $dbDetails = array_reverse( explode( '.', $name, 2 ) );
                if ( isset( $dbDetails[1] ) ) {
-                       @list( $table, $database ) = $dbDetails;
+                       list( $table, $database ) = $dbDetails;
                } else {
-                       @list( $table ) = $dbDetails;
+                       list( $table ) = $dbDetails;
                }
                $prefix = $this->mTablePrefix; # Default prefix
 
index 732b387..b7fb1b2 100644 (file)
@@ -17,7 +17,7 @@ class DBError extends MWException {
         * @param $error String A simple error message to be used for debugging
         */
        function __construct( DatabaseBase &$db, $error ) {
-               $this->db =& $db;
+               $this->db = $db;
                parent::__construct( $error );
        }
 
@@ -178,13 +178,13 @@ class DBConnectionError extends DBError {
         * @return string
         */
        function searchForm() {
-               global $wgSitename, $wgServer;
+               global $wgSitename, $wgServer, $wgRequest;
 
                $usegoogle = htmlspecialchars( $this->msg( 'dberr-usegoogle', 'You can try searching via Google in the meantime.' ) );
                $outofdate = htmlspecialchars( $this->msg( 'dberr-outofdate', 'Note that their indexes of our content may be out of date.' ) );
                $googlesearch = htmlspecialchars( $this->msg( 'searchbutton', 'Search' ) );
 
-               $search = htmlspecialchars( @$_REQUEST['search'] );
+               $search = htmlspecialchars( $wgRequest->getVal( 'search' ) );
 
                $server = htmlspecialchars( $wgServer );
                $sitename = htmlspecialchars( $wgSitename );
index 661b892..147b9d5 100644 (file)
@@ -379,7 +379,9 @@ class DatabaseIbm_db2 extends DatabaseBase {
         * Opens a cataloged database connection, sets mConn
         */
        protected function openCataloged( $dbName, $user, $password ) {
-               @$this->mConn = db2_pconnect( $dbName, $user, $password );
+               wfSuppressWarnings();
+               $this->mConn = db2_pconnect( $dbName, $user, $password );
+               wfRestoreWarnings();
        }
 
        /**
@@ -388,7 +390,9 @@ class DatabaseIbm_db2 extends DatabaseBase {
        protected function openUncataloged( $dbName, $user, $password, $server, $port )
        {
                $dsn = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$dbName;CHARSET=UTF-8;HOSTNAME=$server;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
-               @$this->mConn = db2_pconnect($dsn, "", "", array());
+               wfSuppressWarnings();
+               $this->mConn = db2_pconnect($dsn, "", "", array());
+               wfRestoreWarnings();
        }
 
        /**
@@ -501,7 +505,7 @@ class DatabaseIbm_db2 extends DatabaseBase {
                }
 
                // If the table exists, there should be one of it
-               @$row = $this->fetchRow( $res );
+               $row = $this->fetchRow( $res );
                $count = $row[0];
                if ( $count == '1' || $count == 1 ) {
                        return true;
@@ -523,7 +527,9 @@ class DatabaseIbm_db2 extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @$row = db2_fetch_object( $res );
+               wfSuppressWarnings();
+               $row = db2_fetch_object( $res );
+               wfRestoreWarnings();
                if( $this->lastErrno() ) {
                        throw new DBUnexpectedError( $this, 'Error in fetchObject(): '
                                . htmlspecialchars( $this->lastError() ) );
@@ -544,7 +550,9 @@ class DatabaseIbm_db2 extends DatabaseBase {
                        $res = $res->result;
                }
                if ( db2_num_rows( $res ) > 0) {
-                       @$row = db2_fetch_array( $res );
+                       wfSuppressWarnings();
+                       $row = db2_fetch_array( $res );
+                       wfRestoreWarnings();
                        if ( $this->lastErrno() ) {
                                throw new DBUnexpectedError( $this, 'Error in fetchRow(): '
                                        . htmlspecialchars( $this->lastError() ) );
@@ -1072,7 +1080,10 @@ class DatabaseIbm_db2 extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               if ( !@db2_free_result( $res ) ) {
+               wfSuppressWarnings();
+               $ok = db2_free_result( $res );
+               wfRestoreWarnings();
+               if ( !$ok ) {
                        throw new DBUnexpectedError( $this, "Unable to free DB2 result\n" );
                }
        }
index d5e8d19..b2aac5d 100644 (file)
@@ -95,7 +95,9 @@ class DatabaseMysql extends DatabaseBase {
                wfProfileOut("dbconnect-$server");
 
                if ( $dbName != '' && $this->mConn !== false ) {
-                       $success = @/**/mysql_select_db( $dbName, $this->mConn );
+                       wfSuppressWarnings();
+                       $success = mysql_select_db( $dbName, $this->mConn );
+                       wfRestoreWarnings();
                        if ( !$success ) {
                                $error = "Error selecting database $dbName on server {$this->mServer} " .
                                        "from client host " . wfHostname() . "\n";
@@ -152,7 +154,10 @@ class DatabaseMysql extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               if ( !@/**/mysql_free_result( $res ) ) {
+               wfSuppressWarnings();
+               $ok = mysql_free_result( $res );
+               wfRestoreWarnings();
+               if ( !$ok ) {
                        throw new DBUnexpectedError( $this, "Unable to free MySQL result" );
                }
        }
@@ -161,7 +166,9 @@ class DatabaseMysql extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @/**/$row = mysql_fetch_object( $res );
+               wfSuppressWarnings();
+               $row = mysql_fetch_object( $res );
+               wfRestoreWarnings();
                if( $this->lastErrno() ) {
                        throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) );
                }
@@ -172,7 +179,9 @@ class DatabaseMysql extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @/**/$row = mysql_fetch_array( $res );
+               wfSuppressWarnings();
+               $row = mysql_fetch_array( $res );
+               wfRestoreWarnings();
                if ( $this->lastErrno() ) {
                        throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) );
                }
@@ -183,7 +192,9 @@ class DatabaseMysql extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @/**/$n = mysql_num_rows( $res );
+               wfSuppressWarnings();
+               $n = mysql_num_rows( $res );
+               wfRestoreWarnings();
                if( $this->lastErrno() ) {
                        throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) );
                }
index 74316cf..742a8b5 100644 (file)
@@ -263,7 +263,10 @@ class DatabasePostgres extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               if ( !@pg_free_result( $res ) ) {
+               wfSuppressWarnings();
+               $ok = pg_free_result( $res );
+               wfRestoreWarnings();
+               if ( !$ok ) {
                        throw new DBUnexpectedError( $this, "Unable to free Postgres result\n" );
                }
        }
@@ -272,7 +275,9 @@ class DatabasePostgres extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @$row = pg_fetch_object( $res );
+               wfSuppressWarnings();
+               $row = pg_fetch_object( $res );
+               wfRestoreWarnings();
                # @todo FIXME: HACK HACK HACK HACK debug
 
                # @todo hashar: not sure if the following test really trigger if the object
@@ -287,7 +292,9 @@ class DatabasePostgres extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @$row = pg_fetch_array( $res );
+               wfSuppressWarnings();
+               $row = pg_fetch_array( $res );
+               wfRestoreWarnings();
                if( pg_last_error( $this->mConn ) ) {
                        throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) );
                }
@@ -298,7 +305,9 @@ class DatabasePostgres extends DatabaseBase {
                if ( $res instanceof ResultWrapper ) {
                        $res = $res->result;
                }
-               @$n = pg_num_rows( $res );
+               wfSuppressWarnings();
+               $n = pg_num_rows( $res );
+               wfRestoreWarnings();
                if( pg_last_error( $this->mConn ) ) {
                        throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) );
                }