Add missing wfProfileOut before throwing an exception
[lhc/web/wiklou.git] / includes / db / DatabaseMysql.php
index c5100b5..d6f6809 100644 (file)
@@ -68,6 +68,7 @@ class DatabaseMysql extends DatabaseBase {
                # Fail now
                # Otherwise we get a suppressed fatal error, which is very hard to track down
                if ( !function_exists( 'mysql_connect' ) ) {
+                       wfProfileOut( __METHOD__ );
                        throw new DBConnectionError( $this, "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
                }
 
@@ -193,7 +194,7 @@ class DatabaseMysql extends DatabaseBase {
 
        /**
         * @param $res ResultWrapper
-        * @return object|stdClass
+        * @return object|bool
         * @throws DBUnexpectedError
         */
        function fetchObject( $res ) {
@@ -208,7 +209,7 @@ class DatabaseMysql extends DatabaseBase {
                // Unfortunately, mysql_fetch_object does not reset the last errno.
                // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
                // these are the only errors mysql_fetch_object can cause.
-               // See http://dev.mysql.com/doc/refman/5.0/es/mysql-fetch-row.html.
+               // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
                if( $errno == 2000 || $errno == 2013 ) {
                        throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) );
                }
@@ -217,7 +218,7 @@ class DatabaseMysql extends DatabaseBase {
 
        /**
         * @param $res ResultWrapper
-        * @return array
+        * @return array|bool
         * @throws DBUnexpectedError
         */
        function fetchRow( $res ) {
@@ -232,7 +233,7 @@ class DatabaseMysql extends DatabaseBase {
                // Unfortunately, mysql_fetch_array does not reset the last errno.
                // Only check for CR_SERVER_LOST and CR_UNKNOWN_ERROR, as
                // these are the only errors mysql_fetch_object can cause.
-               // See http://dev.mysql.com/doc/refman/5.0/es/mysql-fetch-row.html.
+               // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
                if( $errno == 2000 || $errno == 2013 ) {
                        throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) );
                }
@@ -251,9 +252,11 @@ class DatabaseMysql extends DatabaseBase {
                wfSuppressWarnings();
                $n = mysql_num_rows( $res );
                wfRestoreWarnings();
-               if( $this->lastErrno() ) {
-                       throw new DBUnexpectedError( $this, 'Error in numRows(): ' . htmlspecialchars( $this->lastError() ) );
-               }
+               // Unfortunately, mysql_num_rows does not reset the last errno.
+               // We are not checking for any errors here, since
+               // these are no errors mysql_num_rows can cause.
+               // See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
+               // See https://bugzilla.wikimedia.org/42430
                return $n;
        }
 
@@ -695,8 +698,8 @@ class DatabaseMysql extends DatabaseBase {
        /**
         * Check to see if a named lock is available. This is non-blocking.
         *
-        * @param $lockName String: name of lock to poll
-        * @param $method String: name of method calling us
+        * @param string $lockName name of lock to poll
+        * @param string $method name of method calling us
         * @return Boolean
         * @since 1.20
         */
@@ -744,6 +747,7 @@ class DatabaseMysql extends DatabaseBase {
         * @param $write array
         * @param $method string
         * @param $lowPriority bool
+        * @return bool
         */
        public function lockTables( $read, $write, $method, $lowPriority = true ) {
                $items = array();
@@ -759,13 +763,16 @@ class DatabaseMysql extends DatabaseBase {
                }
                $sql = "LOCK TABLES " . implode( ',', $items );
                $this->query( $sql, $method );
+               return true;
        }
 
        /**
         * @param $method string
+        * @return bool
         */
        public function unlockTables( $method ) {
                $this->query( "UNLOCK TABLES", $method );
+               return true;
        }
 
        /**
@@ -889,8 +896,8 @@ class DatabaseMysql extends DatabaseBase {
        /**
         * List all tables on the database
         *
-        * @param $prefix string Only show tables with this prefix, e.g. mw_
-        * @param $fname String: calling function name
+        * @param string $prefix Only show tables with this prefix, e.g. mw_
+        * @param string $fname calling function name
         * @return array
         */
        function listTables( $prefix = null, $fname = 'DatabaseMysql::listTables' ) {
@@ -959,7 +966,7 @@ class MySQLField implements Field {
        private $name, $tablename, $default, $max_length, $nullable,
                $is_pk, $is_unique, $is_multiple, $is_key, $type;
 
-       function __construct ( $info ) {
+       function __construct( $info ) {
                $this->name = $info->name;
                $this->tablename = $info->table;
                $this->default = $info->def;