database: Fix various scalar and null types
Fix return values to match documentation Provide fallback if no null value is allowed Return from inside of try/finally makes it clear for static analyzer Change-Id: I8bdfa453fc56dc50749cbd324b3d0d36e8e7065e
This commit is contained in:
parent
0cf01bc091
commit
478c4892f6
3 changed files with 14 additions and 14 deletions
|
|
@ -105,7 +105,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
protected $flags;
|
||||
/** @var array Current LoadBalancer tracking information */
|
||||
protected $lbInfo = [];
|
||||
/** @var string Current SQL query delimiter */
|
||||
/** @var string|false Current SQL query delimiter */
|
||||
protected $delimiter = ';';
|
||||
/** @var array[] Current map of (table => (dbname, schema, prefix) map) */
|
||||
protected $tableAliases = [];
|
||||
|
|
@ -2313,7 +2313,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
$indexInfo = $this->indexInfo( $table, $index, $fname );
|
||||
|
||||
if ( !$indexInfo ) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return !$indexInfo[0]->Non_unique;
|
||||
|
|
@ -2687,7 +2687,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
) {
|
||||
$fld = "GROUP_CONCAT($field SEPARATOR " . $this->addQuotes( $delim ) . ')';
|
||||
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, null, [], $join_conds ) . ')';
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, __METHOD__, [], $join_conds ) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2893,7 +2893,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
}
|
||||
|
||||
public function getServerName() {
|
||||
return $this->serverName ?? $this->getServer();
|
||||
return $this->serverName ?? $this->getServer() ?? 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -4885,7 +4885,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
}
|
||||
|
||||
try {
|
||||
$error = $this->sourceStream(
|
||||
return $this->sourceStream(
|
||||
$fp,
|
||||
$lineCallback,
|
||||
$resultCallback,
|
||||
|
|
@ -4895,8 +4895,6 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
} finally {
|
||||
fclose( $fp );
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
public function setSchemaVars( $vars ) {
|
||||
|
|
|
|||
|
|
@ -265,10 +265,12 @@ class DatabasePostgres extends Database {
|
|||
|
||||
public function lastErrno() {
|
||||
if ( $this->lastResultHandle ) {
|
||||
return pg_result_error_field( $this->lastResultHandle, PGSQL_DIAG_SQLSTATE );
|
||||
} else {
|
||||
return false;
|
||||
$lastErrno = pg_result_error_field( $this->lastResultHandle, PGSQL_DIAG_SQLSTATE );
|
||||
if ( $lastErrno !== false ) {
|
||||
return (int)$lastErrno;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function fetchAffectedRowCount() {
|
||||
|
|
@ -407,7 +409,7 @@ __INDEXATTR__;
|
|||
")'";
|
||||
$res = $this->query( $sql, $fname, $flags );
|
||||
if ( !$res ) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return $res->numRows() > 0;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ interface IDatabase {
|
|||
* Keys matching the IDatabase::LB_* constants are also used internally by subclasses
|
||||
*
|
||||
* @param array|string $nameOrArray The new array or the name of a key to set
|
||||
* @param array|null $value If $nameOrArray is a string, the new key value (null to unset)
|
||||
* @param array|mixed|null $value If $nameOrArray is a string, the new key value (null to unset)
|
||||
*/
|
||||
public function setLBInfo( $nameOrArray, $value = null );
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ interface IDatabase {
|
|||
/**
|
||||
* Get the last time the connection may have been used for a write query
|
||||
*
|
||||
* @return int|float UNIX timestamp or false
|
||||
* @return int|float|false UNIX timestamp or false
|
||||
* @since 1.24
|
||||
*/
|
||||
public function lastDoneWrites();
|
||||
|
|
@ -2190,7 +2190,7 @@ interface IDatabase {
|
|||
* @param string $method Name of the calling method
|
||||
* @param int $timeout Acquisition timeout in seconds (0 means non-blocking)
|
||||
* @param int $flags Bit field of IDatabase::LOCK_* constants
|
||||
* @return bool Success
|
||||
* @return bool|float Success
|
||||
* @throws DBError If an error occurs, {@see query}
|
||||
*/
|
||||
public function lock( $lockName, $method, $timeout = 5, $flags = 0 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue