# 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" );
}
/**
* @param $res ResultWrapper
- * @return object|stdClass
+ * @return object|bool
* @throws DBUnexpectedError
*/
function fetchObject( $res ) {
// 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() ) );
}
/**
* @param $res ResultWrapper
- * @return array
+ * @return array|bool
* @throws DBUnexpectedError
*/
function fetchRow( $res ) {
// 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() ) );
}
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;
}
/**
* 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
*/
* @param $write array
* @param $method string
* @param $lowPriority bool
+ * @return bool
*/
public function lockTables( $read, $write, $method, $lowPriority = true ) {
$items = array();
}
$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;
}
/**
/**
* 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' ) {
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;