From e22a70a1037b09235591197b0bbf9f228a301a2f Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 27 Dec 2013 02:54:51 +0100 Subject: [PATCH] Update documentation for database related classes Change-Id: I364e192e2624f89a91dcb19e371ce3412142a95f --- includes/db/ChronologyProtector.php | 12 +- includes/db/CloneDatabase.php | 39 +- includes/db/Database.php | 528 ++++++++++++++-------------- includes/db/DatabaseError.php | 42 ++- includes/db/DatabaseMssql.php | 141 ++++++-- includes/db/DatabaseMysql.php | 12 +- includes/db/DatabaseMysqlBase.php | 159 +++++---- includes/db/DatabaseMysqli.php | 59 +++- includes/db/DatabaseOracle.php | 80 ++++- includes/db/DatabasePostgres.php | 117 ++++-- includes/db/DatabaseSqlite.php | 108 +++--- includes/db/DatabaseUtility.php | 9 +- includes/db/LBFactory.php | 46 +-- includes/db/LBFactoryMulti.php | 34 +- includes/db/LBFactorySingle.php | 25 +- includes/db/LoadBalancer.php | 60 ++-- includes/db/LoadMonitor.php | 32 +- includes/db/ORMTable.php | 8 +- 18 files changed, 870 insertions(+), 641 deletions(-) diff --git a/includes/db/ChronologyProtector.php b/includes/db/ChronologyProtector.php index 3d1f453c30..0c7b612eba 100644 --- a/includes/db/ChronologyProtector.php +++ b/includes/db/ChronologyProtector.php @@ -26,12 +26,14 @@ * Kind of like Hawking's [[Chronology Protection Agency]]. */ class ChronologyProtector { - /** @var Array (DB master name => position) */ + /** @var array (DB master name => position) */ protected $startupPositions = array(); - /** @var Array (DB master name => position) */ + + /** @var array (DB master name => position) */ protected $shutdownPositions = array(); - protected $initialized = false; // bool; whether the session data was loaded + /** @var bool Whether the session data was loaded */ + protected $initialized = false; /** * Initialise a LoadBalancer to give it appropriate chronology protection. @@ -41,7 +43,7 @@ class ChronologyProtector { * to that position by delaying execution. The delay may timeout and allow stale * data if no non-lagged slaves are available. * - * @param $lb LoadBalancer + * @param LoadBalancer $lb * @return void */ public function initLB( LoadBalancer $lb ) { @@ -67,7 +69,7 @@ class ChronologyProtector { * Notify the ChronologyProtector that the LoadBalancer is about to shut * down. Saves replication positions. * - * @param $lb LoadBalancer + * @param LoadBalancer $lb * @return void */ public function shutdownLB( LoadBalancer $lb ) { diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index 1e01d29762..c5dc882e10 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -25,44 +25,29 @@ */ class CloneDatabase { - /** - * Table prefix for cloning - * @var String - */ + /** @var string Table prefix for cloning */ private $newTablePrefix = ''; - /** - * Current table prefix - * @var String - */ + /** @var string Current table prefix */ private $oldTablePrefix = ''; - /** - * List of tables to be cloned - * @var Array - */ + /** @var array List of tables to be cloned */ private $tablesToClone = array(); - /** - * Should we DROP tables containing the new names? - * @var Bool - */ + /** @var bool Should we DROP tables containing the new names? */ private $dropCurrentTables = true; - /** - * Whether to use temporary tables or not - * @var Bool - */ + /** @var bool Whether to use temporary tables or not */ private $useTemporaryTables = true; /** * Constructor * - * @param $db DatabaseBase A database subclass + * @param DatabaseBase $db A database subclass * @param array $tablesToClone An array of tables to clone, unprefixed * @param string $newTablePrefix Prefix to assign to the tables * @param string $oldTablePrefix Prefix on current tables, if not $wgDBprefix - * @param $dropCurrentTables bool + * @param bool $dropCurrentTables */ public function __construct( DatabaseBase $db, array $tablesToClone, $newTablePrefix, $oldTablePrefix = '', $dropCurrentTables = true @@ -128,7 +113,7 @@ class CloneDatabase { /** * Change the table prefix on all open DB connections/ * - * @param $prefix + * @param string $prefix * @return void */ public static function changePrefix( $prefix ) { @@ -138,8 +123,8 @@ class CloneDatabase { } /** - * @param $lb LoadBalancer - * @param $prefix + * @param LoadBalancer $lb + * @param string $prefix * @return void */ public static function changeLBPrefix( $lb, $prefix ) { @@ -147,8 +132,8 @@ class CloneDatabase { } /** - * @param $db DatabaseBase - * @param $prefix + * @param DatabaseBase $db + * @param string $prefix * @return void */ public static function changeDBPrefix( $db, $prefix ) { diff --git a/includes/db/Database.php b/includes/db/Database.php index 2e19f6acbd..57575ec881 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -57,8 +57,8 @@ interface DatabaseType { * member variables. * If no more rows are available, false is returned. * - * @param $res ResultWrapper|object as returned from DatabaseBase::query(), etc. - * @return object|bool + * @param ResultWrapper|stdClass $res Object as returned from DatabaseBase::query(), etc. + * @return stdClass|bool * @throws DBUnexpectedError Thrown if the database returns an error */ function fetchObject( $res ); @@ -68,7 +68,7 @@ interface DatabaseType { * form. Fields are retrieved with $row['fieldname']. * If no more rows are available, false is returned. * - * @param $res ResultWrapper result object as returned from DatabaseBase::query(), etc. + * @param ResultWrapper $res Result object as returned from DatabaseBase::query(), etc. * @return array|bool * @throws DBUnexpectedError Thrown if the database returns an error */ @@ -77,7 +77,7 @@ interface DatabaseType { /** * Get the number of rows in a result object * - * @param $res Mixed: A SQL result + * @param mixed $res A SQL result * @return int */ function numRows( $res ); @@ -86,7 +86,7 @@ interface DatabaseType { * Get the number of fields in a result object * @see http://www.php.net/mysql_num_fields * - * @param $res Mixed: A SQL result + * @param mixed $res A SQL result * @return int */ function numFields( $res ); @@ -95,8 +95,8 @@ interface DatabaseType { * Get a field name in a result object * @see http://www.php.net/mysql_field_name * - * @param $res Mixed: A SQL result - * @param $n Integer + * @param mixed $res A SQL result + * @param int $n * @return string */ function fieldName( $res, $n ); @@ -119,8 +119,8 @@ interface DatabaseType { * Change the position of the cursor in a result object * @see http://www.php.net/mysql_data_seek * - * @param $res Mixed: A SQL result - * @param $row Mixed: Either MySQL row or ResultWrapper + * @param mixed $res A SQL result + * @param int $row */ function dataSeek( $res, $row ); @@ -144,8 +144,8 @@ interface DatabaseType { * mysql_fetch_field() wrapper * Returns false if the field doesn't exist * - * @param string $table table name - * @param string $field field name + * @param string $table Table name + * @param string $field Field name * * @return Field */ @@ -156,7 +156,7 @@ interface DatabaseType { * @param string $table Table name * @param string $index Index name * @param string $fname Calling function name - * @return Mixed: Database-specific index description class or false if the index does not exist + * @return mixed Database-specific index description class or false if the index does not exist */ function indexInfo( $table, $index, $fname = __METHOD__ ); @@ -171,8 +171,8 @@ interface DatabaseType { /** * Wrapper for addslashes() * - * @param string $s to be slashed. - * @return string: slashed string. + * @param string $s String to be slashed. + * @return string Slashed string. */ function strencode( $s ); @@ -182,7 +182,7 @@ interface DatabaseType { * Should at least contain plain text, if for some reason * your database has no website. * - * @return string: wikitext of a link to the server software's web site + * @return string Wikitext of a link to the server software's web site */ function getSoftwareLink(); @@ -190,7 +190,7 @@ interface DatabaseType { * A string describing the current software version, like from * mysql_get_server_info(). * - * @return string: Version information from the database server. + * @return string Version information from the database server. */ function getServerVersion(); @@ -199,7 +199,7 @@ interface DatabaseType { * other details in a user-friendly way. Will be listed on Special:Version, etc. * Use getServerVersion() to get machine-friendly information. * - * @return string: Version information from the database server + * @return string Version information from the database server */ function getServerInfo(); } @@ -218,8 +218,10 @@ interface IDatabase { abstract class DatabaseBase implements IDatabase, DatabaseType { /** Number of times to re-try an operation in case of deadlock */ const DEADLOCK_TRIES = 4; + /** Minimum time to wait before retry, in microseconds */ const DEADLOCK_DELAY_MIN = 500000; + /** Maximum time to wait before retry */ const DEADLOCK_DELAY_MAX = 1500000; @@ -233,6 +235,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { protected $mServer, $mUser, $mPassword, $mDBname; + /** @var resource Database connection */ protected $mConn = null; protected $mOpened = false; @@ -268,7 +271,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Remembers the function name given for starting the most recent transaction via begin(). * Used to provide additional context for error reporting. * - * @var String + * @var string * @see DatabaseBase::mTrxLevel */ private $mTrxFname = null; @@ -276,7 +279,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Record if possible write queries were done in the last transaction started * - * @var Bool + * @var bool * @see DatabaseBase::mTrxLevel */ private $mTrxDoneWrites = false; @@ -284,7 +287,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Record if the current transaction was started implicitly due to DBO_TRX being set. * - * @var Bool + * @var bool * @see DatabaseBase::mTrxLevel */ private $mTrxAutomatic = false; @@ -299,19 +302,19 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Record if the current transaction was started implicitly by DatabaseBase::startAtomic * - * @var Bool + * @var bool */ private $mTrxAutomaticAtomic = false; /** * @since 1.21 - * @var file handle for upgrade + * @var resource File handle for upgrade */ protected $fileHandle = null; /** * @since 1.22 - * @var Process cache of VIEWs names in the database + * @var string[] Process cache of VIEWs names in the database */ protected $allViews = null; @@ -325,14 +328,14 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * other details in a user-friendly way. Will be listed on Special:Version, etc. * Use getServerVersion() to get machine-friendly information. * - * @return string: Version information from the database server + * @return string Version information from the database server */ public function getServerInfo() { return $this->getServerVersion(); } /** - * @return string: command delimiter used by this database engine + * @return string command delimiter used by this database engine */ public function getDelimiter() { return $this->delimiter; @@ -340,7 +343,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Boolean, controls output of large amounts of debug information. - * @param $debug bool|null + * @param bool|null $debug * - true to enable debugging * - false to disable debugging * - omitted or null to do nothing @@ -369,8 +372,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * split up queries into batches using a LIMIT clause than to switch off * buffering. * - * @param $buffer null|bool - * + * @param null|bool $buffer * @return null|bool The previous value of the flag */ public function bufferResults( $buffer = null ) { @@ -390,8 +392,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * Do not use this function outside of the Database classes. * - * @param $ignoreErrors bool|null - * + * @param null|bool $ignoreErrors * @return bool The previous value of the flag. */ public function ignoreErrors( $ignoreErrors = null ) { @@ -431,7 +432,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Set the filehandle to copy write statements to. * - * @param $fh filehandle + * @param resource $fh File handle */ public function setFileHandle( $fh ) { $this->fileHandle = $fh; @@ -463,7 +464,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * the LB info array is set to that parameter. If it is called with two * parameters, the member with the given name is set to the given value. * - * @param $name + * @param string $name * @param $value */ public function setLBInfo( $name, $value = null ) { @@ -477,7 +478,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Set lag time in seconds for a fake slave * - * @param $lag int + * @param int $lag */ public function setFakeSlaveLag( $lag ) { $this->mFakeSlaveLag = $lag; @@ -486,7 +487,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Make this connection a fake master * - * @param $enabled bool + * @param bool $enabled */ public function setFakeMaster( $enabled = true ) { $this->mFakeMaster = $enabled; @@ -569,7 +570,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Return the last query that went through DatabaseBase::query() - * @return String + * @return string */ public function lastQuery() { return $this->mLastQuery; @@ -599,7 +600,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Is a connection to the database open? - * @return Boolean + * @return bool */ public function isOpen() { return $this->mOpened; @@ -608,7 +609,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Set a flag for this connection * - * @param $flag Integer: DBO_* constants from Defines.php: + * @param int $flag DBO_* constants from Defines.php: * - DBO_DEBUG: output some debug info (same as debug()) * - DBO_NOBUFFER: don't buffer results (inverse of bufferResults()) * - DBO_TRX: automatically start transactions @@ -627,7 +628,13 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Clear a flag for this connection * - * @param $flag : same as setFlag()'s $flag param + * @param int $flag DBO_* constants from Defines.php: + * - DBO_DEBUG: output some debug info (same as debug()) + * - DBO_NOBUFFER: don't buffer results (inverse of bufferResults()) + * - DBO_TRX: automatically start transactions + * - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode + * and removes it in command line mode + * - DBO_PERSISTENT: use persistant database connection */ public function clearFlag( $flag ) { global $wgDebugDBTransactions; @@ -640,8 +647,14 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Returns a boolean whether the flag $flag is set for this connection * - * @param $flag : same as setFlag()'s $flag param - * @return Boolean + * @param int $flag DBO_* constants from Defines.php: + * - DBO_DEBUG: output some debug info (same as debug()) + * - DBO_NOBUFFER: don't buffer results (inverse of bufferResults()) + * - DBO_TRX: automatically start transactions + * - DBO_DEFAULT: automatically sets DBO_TRX if not in command line mode + * and removes it in command line mode + * - DBO_PERSISTENT: use persistant database connection + * @return bool */ public function getFlag( $flag ) { return !!( $this->mFlags & $flag ); @@ -650,8 +663,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * General read-only accessor * - * @param $name string - * + * @param string $name * @return string */ public function getProperty( $name ) { @@ -697,7 +709,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * DatabaseBase subclasses should not be constructed directly in external * code. DatabaseBase::factory() should be used instead. * - * @param array Parameters passed from DatabaseBase::factory() + * @param array $params Parameters passed from DatabaseBase::factory() */ function __construct( $params = null ) { global $wgDBprefix, $wgCommandLineMode, $wgDebugDBTransactions; @@ -782,7 +794,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string $dbType A possible DB type * @param array $p An array of options to pass to the constructor. * Valid options are: host, user, password, dbname, flags, tablePrefix, driver - * @return DatabaseBase subclass or null + * @throws MWException + * @return DatabaseBase|null DatabaseBase subclass or null */ final public static function factory( $dbType, $p = array() ) { $canonicalDBTypes = array( @@ -864,8 +877,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * @param $errno - * @param $errstr - * @access private + * @param string $errstr */ public function connectionErrorHandler( $errno, $errstr ) { $this->mPHPError = $errstr; @@ -876,7 +888,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * if it is open : commits any open transactions * * @throws MWException - * @return Bool operation success. true if already closed. + * @return bool Operation success. true if already closed. */ public function close() { if ( count( $this->mTrxIdleCallbacks ) ) { // sanity @@ -905,12 +917,12 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Closes underlying database connection * @since 1.20 - * @return bool: Whether connection was closed successfully + * @return bool Whether connection was closed successfully */ abstract protected function closeConnection(); /** - * @param string $error fallback error message, used if none is given by DB + * @param string $error Fallback error message, used if none is given by DB * @throws DBConnectionError */ function reportConnectionError( $error = 'Unknown error' ) { @@ -926,8 +938,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * The DBMS-dependent part of query() * - * @param $sql String: SQL query. - * @return ResultWrapper Result object to feed to fetchObject, fetchRow, ...; or false on failure + * @param string $sql SQL query. + * @return ResultWrapper|bool Result object to feed to fetchObject, + * fetchRow, ...; or false on failure */ abstract protected function doQuery( $sql ); @@ -935,8 +948,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Determine whether a query writes to the DB. * Should return true if unsure. * - * @param $sql string - * + * @param string $sql * @return bool */ public function isWriteQuery( $sql ) { @@ -956,13 +968,13 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * However, the query wrappers themselves should call this function. * - * @param $sql String: SQL query - * @param $fname String: Name of the calling function, for profiling/SHOW PROCESSLIST + * @param string $sql SQL query + * @param string $fname Name of the calling function, for profiling/SHOW PROCESSLIST * comment (you can use __METHOD__ or add some extra info) - * @param $tempIgnore Boolean: Whether to avoid throwing an exception on errors... + * @param bool $tempIgnore Whether to avoid throwing an exception on errors... * maybe best to catch the exception instead? * @throws MWException - * @return boolean|ResultWrapper. true for a successful write query, ResultWrapper object + * @return bool|ResultWrapper True for a successful write query, ResultWrapper object * for a successful read query, or false on failure if $tempIgnore set */ public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) { @@ -1014,6 +1026,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } $isMaster = !is_null( $this->getLBInfo( 'master' ) ); + if ( !Profiler::instance()->isStub() ) { # generalizeSQL will probably cut down the query to reasonable # logging size most of the time. The substr is really just a sanity check. @@ -1089,11 +1102,11 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Report a query error. Log the error, and if neither the object ignore * flag nor the $tempIgnore flag is set, throw a DBQueryError. * - * @param $error String - * @param $errno Integer - * @param $sql String - * @param $fname String - * @param $tempIgnore Boolean + * @param string $error + * @param int $errno + * @param string $sql + * @param string $fname + * @param bool $tempIgnore * @throws DBQueryError */ public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { @@ -1121,8 +1134,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * & = filename; reads the file and inserts as a blob * (we don't use this though...) * - * @param $sql string - * @param $func string + * @param string $sql + * @param string $func * * @return array */ @@ -1135,7 +1148,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Free a prepared query, generated by prepare(). - * @param $prepared + * @param string $prepared */ protected function freePrepared( $prepared ) { /* No-op by default */ @@ -1144,7 +1157,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Execute a prepared query with the various arguments * @param string $prepared the prepared sql - * @param $args Mixed: Either an array here, or put scalars as varargs + * @param mixed $args Either an array here, or put scalars as varargs * * @return ResultWrapper */ @@ -1163,9 +1176,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * For faking prepared SQL statements on DBs that don't support it directly. * - * @param string $preparedQuery a 'preparable' SQL statement - * @param array $args of arguments to fill it with - * @return string executable SQL + * @param string $preparedQuery A 'preparable' SQL statement + * @param array $args of Arguments to fill it with + * @return string Executable SQL */ public function fillPrepared( $preparedQuery, $args ) { reset( $args ); @@ -1180,9 +1193,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * The arguments should be in $this->preparedArgs and must not be touched * while we're doing this. * - * @param $matches Array + * @param array $matches * @throws DBUnexpectedError - * @return String + * @return string */ protected function fillPreparedArg( $matches ) { switch ( $matches[1] ) { @@ -1220,7 +1233,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * necessary to call this, just use unset() or let the variable holding * the result object go out of scope. * - * @param $res Mixed: A SQL result + * @param mixed $res A SQL result */ public function freeResult( $res ) { } @@ -1270,9 +1283,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Returns an optional USE INDEX clause to go after the table, and a * string to go at the end of the query. * - * @param array $options associative array of options to be turned into - * an SQL query, valid keys are listed in the function. - * @return Array + * @param array $options Associative array of options to be turned into + * an SQL query, valid keys are listed in the function. + * @return array * @see DatabaseBase::select() */ public function makeSelectOptions( $options ) { @@ -1354,7 +1367,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Returns an optional GROUP BY with an optional HAVING * - * @param array $options associative array of options + * @param array $options Associative array of options * @return string * @see DatabaseBase::select() * @since 1.21 @@ -1380,7 +1393,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Returns an optional ORDER BY * - * @param array $options associative array of options + * @param array $options Associative array of options * @return string * @see DatabaseBase::select() * @since 1.21 @@ -1406,9 +1419,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string|array $conds Conditions * @param string $fname Caller function name * @param array $options Query options - * @param $join_conds Array Join conditions - * - * @param $table string|array + * @param array $join_conds Join conditions + * + * @param string|array $table * * May be either an array of table names, or a single string holding a table * name. If an array is given, table aliases can be specified, for example: @@ -1423,7 +1436,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * added, and various other table name mappings to be performed. * * - * @param $vars string|array + * @param string|array $vars * * May be either a field name or an array of field names. The field names * can be complete fragments of SQL, for direct inclusion into the SELECT @@ -1437,7 +1450,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * DBMS-independent. * * - * @param $conds string|array + * @param string|array $conds * * May be either a string containing a single condition, or an array of * conditions. If an array is given, the conditions constructed from each @@ -1462,7 +1475,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * - DatabaseBase::conditional() * * - * @param $options string|array + * @param string|array $options * * Optional: Array of query options. Boolean options are specified by * including them in the array as a string value with a numeric key, for @@ -1518,7 +1531,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * - SQL_NO_CACHE * * - * @param $join_conds string|array + * @param string|array $join_conds * * Optional associative array of table-specific join conditions. In the * most common case, this is unnecessary, since the join condition can be @@ -1531,7 +1544,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * array( 'page' => array( 'LEFT JOIN', 'page_latest=rev_id' ) ) * - * @return ResultWrapper. If the query returned no rows, a ResultWrapper + * @return ResultWrapper|bool If the query returned no rows, a ResultWrapper * with no rows in it will be returned. If there was a query error, a * DBQueryError exception will be thrown, except if the "ignore errors" * option was set, in which case false will be returned. @@ -1554,7 +1567,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string|array $conds Conditions * @param string $fname Caller function name * @param string|array $options Query options - * @param $join_conds string|array Join conditions + * @param string|array $join_conds Join conditions * * @return string SQL query string. * @see DatabaseBase::select() @@ -1620,7 +1633,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param array $conds Conditions * @param string $fname Caller function name * @param string|array $options Query options - * @param $join_conds array|string Join conditions + * @param array|string $join_conds Join conditions * * @return stdClass|bool */ @@ -1657,12 +1670,12 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * Takes the same arguments as DatabaseBase::select(). * - * @param string $table table name - * @param array|string $vars : unused - * @param array|string $conds : filters on the table - * @param string $fname function name for profiling - * @param array $options options for select - * @return Integer: row count + * @param string $table Table name + * @param string $vars Unused + * @param array|string $conds Filters on the table + * @param string $fname Function name for profiling + * @param array $options Options for select + * @return int Row count */ public function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() @@ -1710,10 +1723,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Determines whether a field exists in a table * - * @param string $table table name - * @param string $field filed to check on that table - * @param string $fname calling function name (optional) - * @return Boolean: whether $table has filed $field + * @param string $table Table name + * @param string $field Filed to check on that table + * @param string $fname Calling function name (optional) + * @return bool Whether $table has filed $field */ public function fieldExists( $table, $field, $fname = __METHOD__ ) { $info = $this->fieldInfo( $table, $field ); @@ -1726,10 +1739,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Usually throws a DBQueryError on failure * If errors are explicitly ignored, returns NULL on failure * - * @param $table - * @param $index - * @param $fname string - * + * @param string $table + * @param string $index + * @param string $fname * @return bool|null */ public function indexExists( $table, $index, $fname = __METHOD__ ) { @@ -1748,9 +1760,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Query whether a given table exists * - * @param $table string - * @param $fname string - * + * @param string $table + * @param string $fname * @return bool */ public function tableExists( $table, $fname = __METHOD__ ) { @@ -1765,8 +1776,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Determines if a given index is unique * - * @param $table string - * @param $index string + * @param string $table + * @param string $index * * @return bool */ @@ -1783,7 +1794,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Helper for DatabaseBase::insert(). * - * @param $options array + * @param array $options * @return string */ protected function makeInsertOptions( $options ) { @@ -1815,10 +1826,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * possible to determine how many rows were successfully inserted using * DatabaseBase::affectedRows(). * - * @param $table String Table name. This will be passed through - * DatabaseBase::tableName(). - * @param $a Array of rows to insert - * @param $fname String Calling function name (use __METHOD__) for logs/profiling + * @param string $table Table name. This will be passed through + * DatabaseBase::tableName(). + * @param array $a Array of rows to insert + * @param string $fname Calling function name (use __METHOD__) for logs/profiling * @param array $options of options * * @return bool @@ -1902,25 +1913,20 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * UPDATE wrapper. Takes a condition array and a SET array. * - * @param $table String name of the table to UPDATE. This will be passed through - * DatabaseBase::tableName(). - * + * @param string $table Name of the table to UPDATE. This will be passed through + * DatabaseBase::tableName(). * @param array $values An array of values to SET. For each array element, - * the key gives the field name, and the value gives the data - * to set that field to. The data will be quoted by - * DatabaseBase::addQuotes(). - * - * @param $conds Array: An array of conditions (WHERE). See - * DatabaseBase::select() for the details of the format of - * condition arrays. Use '*' to update all rows. - * - * @param $fname String: The function name of the caller (from __METHOD__), - * for logging and profiling. - * + * the key gives the field name, and the value gives the data to set + * that field to. The data will be quoted by DatabaseBase::addQuotes(). + * @param array $conds An array of conditions (WHERE). See + * DatabaseBase::select() for the details of the format of condition + * arrays. Use '*' to update all rows. + * @param string $fname The function name of the caller (from __METHOD__), + * for logging and profiling. * @param array $options An array of UPDATE options, can be: - * - IGNORE: Ignore unique key conflicts - * - LOW_PRIORITY: MySQL-specific, see MySQL manual. - * @return Boolean + * - IGNORE: Ignore unique key conflicts + * - LOW_PRIORITY: MySQL-specific, see MySQL manual. + * @return bool */ function update( $table, $values, $conds, $fname = __METHOD__, $options = array() ) { $table = $this->tableName( $table ); @@ -1936,15 +1942,15 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Makes an encoded list of strings from an array - * @param array $a containing the data + * + * @param array $a Containing the data * @param int $mode Constant - * - LIST_COMMA: comma separated, no field names - * - LIST_AND: ANDed WHERE clause (without the WHERE). See - * the documentation for $conds in DatabaseBase::select(). - * - LIST_OR: ORed WHERE clause (without the WHERE) - * - LIST_SET: comma separated with field names, like a SET clause - * - LIST_NAMES: comma separated field names - * + * - LIST_COMMA: comma separated, no field names + * - LIST_AND: ANDed WHERE clause (without the WHERE). See + * the documentation for $conds in DatabaseBase::select(). + * - LIST_OR: ORed WHERE clause (without the WHERE) + * - LIST_SET: comma separated with field names, like a SET clause + * - LIST_NAMES: comma separated field names * @throws MWException|DBUnexpectedError * @return string */ @@ -2008,9 +2014,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * The keys on each level may be either integers or strings. * * @param array $data organized as 2-d - * array(baseKeyVal => array(subKeyVal => [ignored], ...), ...) - * @param string $baseKey field name to match the base-level keys to (eg 'pl_namespace') - * @param string $subKey field name to match the sub-level keys to (eg 'pl_title') + * array(baseKeyVal => array(subKeyVal => [ignored], ...), ...) + * @param string $baseKey Field name to match the base-level keys to (eg 'pl_namespace') + * @param string $subKey Field name to match the sub-level keys to (eg 'pl_title') * @return Mixed: string SQL fragment, or false if no items in array. */ public function makeWhereFrom2d( $data, $baseKey, $subKey ) { @@ -2036,7 +2042,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Return aggregated value alias * * @param $valuedata - * @param $valuename string + * @param string $valuename * * @return string */ @@ -2045,7 +2051,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } /** - * @param $field + * @param string $field * @return string */ public function bitNot( $field ) { @@ -2053,8 +2059,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } /** - * @param $fieldLeft - * @param $fieldRight + * @param string $fieldLeft + * @param string $fieldRight * @return string */ public function bitAnd( $fieldLeft, $fieldRight ) { @@ -2062,8 +2068,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } /** - * @param $fieldLeft - * @param $fieldRight + * @param string $fieldLeft + * @param string $fieldRight * @return string */ public function bitOr( $fieldLeft, $fieldRight ) { @@ -2072,8 +2078,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Build a concatenation list to feed into a SQL query - * @param array $stringList list of raw SQL expressions; caller is responsible for any quoting - * @return String + * @param array $stringList List of raw SQL expressions; caller is + * responsible for any quoting + * @return string */ public function buildConcat( $stringList ) { return 'CONCAT(' . implode( ',', $stringList ) . ')'; @@ -2092,7 +2099,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string $field Field name * @param string|array $conds Conditions * @param string|array $join_conds Join conditions - * @return String SQL text + * @return string SQL text * @since 1.23 */ public function buildGroupConcatField( @@ -2145,12 +2152,12 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * themselves. Pass the canonical name to such functions. This is only needed * when calling query() directly. * - * @param string $name database table name + * @param string $name Database table name * @param string $format One of: * quoted - Automatically pass the table name through addIdentifierQuotes() * so that it can be used in a query. * raw - Do not add identifier quotes to the table name - * @return String: full database name + * @return string Full database name */ public function tableName( $name, $format = 'quoted' ) { global $wgSharedDB, $wgSharedPrefix, $wgSharedTables; @@ -2276,8 +2283,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Gets an array of aliased table names * - * @param $tables array( [alias] => table ) - * @return array of strings, see tableNameWithAlias() + * @param array $tables array( [alias] => table ) + * @return string[] See tableNameWithAlias() */ public function tableNamesWithAlias( $tables ) { $retval = array(); @@ -2310,8 +2317,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Gets an array of aliased field names * - * @param $fields array( [alias] => field ) - * @return array of strings, see fieldNameWithAlias() + * @param array $fields array( [alias] => field ) + * @return string[] See fieldNameWithAlias() */ public function fieldNamesWithAlias( $fields ) { $retval = array(); @@ -2330,8 +2337,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * which might have a JOIN and/or USE INDEX clause * * @param array $tables ( [alias] => table ) - * @param $use_index array Same as for select() - * @param $join_conds array Same as for select() + * @param array $use_index Same as for select() + * @param array $join_conds Same as for select() * @return string */ protected function tableNamesWithUseIndexOrJOIN( @@ -2389,8 +2396,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Get the name of an index in a given table * - * @param $index - * + * @param string $index * @return string */ protected function indexName( $index ) { @@ -2411,8 +2417,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Adds quotes and backslashes. * - * @param $s string - * + * @param string $s * @return string */ public function addQuotes( $s ) { @@ -2433,8 +2438,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Since MySQL is the odd one out here the double quotes are our generic * and we implement backticks in DatabaseMysql. * - * @param $s string - * + * @param string $s * @return string */ public function addIdentifierQuotes( $s ) { @@ -2445,16 +2449,15 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Returns if the given identifier looks quoted or not according to * the database convention for quoting identifiers . * - * @param $name string - * - * @return boolean + * @param string $name + * @return bool */ public function isQuotedIdentifier( $name ) { return $name[0] == '"' && substr( $name, -1, 1 ) == '"'; } /** - * @param $s string + * @param string $s * @return string */ protected function escapeLikeInternal( $s ) { @@ -2479,7 +2482,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * $query .= $dbr->buildLike( $pattern ); * * @since 1.16 - * @return String: fully built LIKE statement + * @return string Fully built LIKE statement */ public function buildLike() { $params = func_get_args(); @@ -2527,8 +2530,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Any implementation of this function should *not* involve reusing * sequence numbers created for rolled-back transactions. * See http://bugs.mysql.com/bug.php?id=30767 for details. - * @param $seqName string - * @return null + * @param string $seqName + * @return null|int */ public function nextSequenceValue( $seqName ) { return null; @@ -2541,7 +2544,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * which index to pick. Anyway, other databases might have different * indexes on a given table. So don't bother overriding this unless you're * MySQL. - * @param $index + * @param string $index * @return string */ public function useIndexClause( $index ) { @@ -2564,10 +2567,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * errors which wouldn't have occurred in MySQL. * * @param string $table The table to replace the row(s) in. + * @param array $uniqueIndexes Is an array of indexes. Each element may be either + * a field name or an array of field names * @param array $rows Can be either a single row to insert, or multiple rows, * in the same format as for DatabaseBase::insert() - * @param array $uniqueIndexes is an array of indexes. Each element may be either - * a field name or an array of field names * @param string $fname Calling function name (use __METHOD__) for logs/profiling */ public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) { @@ -2622,7 +2625,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * statement. * * @param string $table Table name - * @param array $rows Rows to insert + * @param array|string $rows Row(s) to insert * @param string $fname Caller function name * * @return ResultWrapper @@ -2673,17 +2676,17 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Usually throws a DBQueryError on failure. If errors are explicitly ignored, * returns success. * + * @since 1.22 + * * @param string $table Table name. This will be passed through DatabaseBase::tableName(). * @param array $rows A single row or list of rows to insert * @param array $uniqueIndexes List of single field names or field name tuples - * @param array $set An array of values to SET. For each array element, - * the key gives the field name, and the value gives the data - * to set that field to. The data will be quoted by - * DatabaseBase::addQuotes(). + * @param array $set An array of values to SET. For each array element, the + * key gives the field name, and the value gives the data to set that + * field to. The data will be quoted by DatabaseBase::addQuotes(). * @param string $fname Calling function name (use __METHOD__) for logs/profiling - * + * @throws Exception * @return bool - * @since 1.22 */ public function upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__ @@ -2747,14 +2750,13 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * DO NOT put the join condition in $conds. * - * @param $delTable String: The table to delete from. - * @param $joinTable String: The other table. - * @param $delVar String: The variable to join on, in the first table. - * @param $joinVar String: The variable to join on, in the second table. - * @param $conds Array: Condition array of field names mapped to variables, - * ANDed together in the WHERE clause - * @param $fname String: Calling function name (use __METHOD__) for - * logs/profiling + * @param string $delTable The table to delete from. + * @param string $joinTable The other table. + * @param string $delVar The variable to join on, in the first table. + * @param string$joinVar The variable to join on, in the second table. + * @param array $conds Condition array of field names mapped to variables, + * ANDed together in the WHERE clause + * @param string $fname Calling function name (use __METHOD__) for logs/profiling * @throws DBUnexpectedError */ public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, @@ -2779,9 +2781,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Returns the size of a text field, or -1 for "unlimited" * - * @param $table string - * @param $field string - * + * @param string $table + * @param string $field * @return int */ public function textFieldSize( $table, $field ) { @@ -2817,10 +2818,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * DELETE query wrapper. * * @param array $table Table name - * @param string|array $conds of conditions. See $conds in DatabaseBase::select() for - * the format. Use $conds == "*" to delete all rows + * @param string|array $conds of conditions. See $conds in DatabaseBase::select() + * for the format. Use $conds == "*" to delete all rows * @param string $fname name of the calling function - * * @throws DBUnexpectedError * @return bool|ResultWrapper */ @@ -2850,7 +2850,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string|array $srcTable May be either a table name, or an array of table names * to include in a join. * - * @param array $varMap must be an associative array of the form + * @param array $varMap Must be an associative array of the form * array( 'dest1' => 'source1', ...). Source items may be literals * rather than field names, but strings should be quoted with * DatabaseBase::addQuotes() @@ -2922,9 +2922,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * likely need to be overridden for most other DBMSes. * * @param string $sql SQL query we will append the limit too - * @param $limit Integer the SQL limit - * @param $offset Integer|bool the SQL offset (default false) - * + * @param int $limit The SQL limit + * @param int|bool $offset The SQL offset (default false) * @throws DBUnexpectedError * @return string */ @@ -2952,8 +2951,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * This is used for providing overload point for other DB abstractions * not compatible with the MySQL syntax. * @param array $sqls SQL statements to combine - * @param $all Boolean: use UNION ALL - * @return String: SQL fragment + * @param bool $all Use UNION ALL + * @return string SQL fragment */ public function unionQueries( $sqls, $all ) { $glue = $all ? ') UNION ALL (' : ') UNION ('; @@ -2968,7 +2967,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param string|array $cond SQL expression which will result in a boolean value * @param string $trueVal SQL expression to return if true * @param string $falseVal SQL expression to return if false - * @return String: SQL fragment + * @return string SQL fragment */ public function conditional( $cond, $trueVal, $falseVal ) { if ( is_array( $cond ) ) { @@ -2982,9 +2981,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Returns a comand for str_replace function in SQL query. * Uses REPLACE() in MySQL * - * @param string $orig column to modify - * @param string $old column to seek - * @param string $new column to replace with + * @param string $orig Column to modify + * @param string $old Column to seek + * @param string $new Column to replace with * * @return string */ @@ -3107,11 +3106,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Wait for the slave to catch up to a given master position. * - * @param $pos DBMasterPos object - * @param $timeout Integer: the maximum number of seconds to wait for + * @param DBMasterPos $pos + * @param int $timeout The maximum number of seconds to wait for * synchronisation - * - * @return integer: zero if the slave was past that position already, + * @return int Zzero if the slave was past that position already, * greater than zero if we waited for some period of time, less than * zero if we timed out. */ @@ -3149,7 +3147,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Get the replication position of this slave * - * @return DBMasterPos, or false if this is not a slave. + * @return DBMasterPos|bool False if this is not a slave. */ public function getSlavePos() { if ( !is_null( $this->mFakeSlaveLag ) ) { @@ -3166,7 +3164,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Get the position of this master * - * @return DBMasterPos, or false if this is not a master + * @return DBMasterPos|bool False if this is not a master */ public function getMasterPos() { if ( $this->mFakeMaster ) { @@ -3340,7 +3338,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * will cause a warning, unless the current transaction was started * automatically because of the DBO_TRX flag. * - * @param $fname string + * @param string $fname * @throws DBError */ final public function begin( $fname = __METHOD__ ) { @@ -3392,7 +3390,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Issues the BEGIN command to the database server. * * @see DatabaseBase::begin() - * @param type $fname + * @param string $fname */ protected function doBegin( $fname ) { $this->query( 'BEGIN', $fname ); @@ -3405,12 +3403,13 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * Nesting of transactions is not supported. * - * @param $fname string + * @param string $fname * @param string $flush Flush flag, set to 'flush' to disable warnings about * explicitly committing implicit transactions, or calling commit when no * transaction is in progress. This will silently break any ongoing * explicit transaction. Only set the flush flag if you are sure that it * is safe to ignore these warnings in your context. + * @throws DBUnexpectedError */ final public function commit( $fname = __METHOD__, $flush = '' ) { if ( !$this->mTrxAtomicLevels->isEmpty() ) { @@ -3447,7 +3446,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Issues the COMMIT command to the database server. * * @see DatabaseBase::commit() - * @param type $fname + * @param string $fname */ protected function doCommit( $fname ) { if ( $this->mTrxLevel ) { @@ -3462,7 +3461,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * No-op on non-transactional databases. * - * @param $fname string + * @param string $fname */ final public function rollback( $fname = __METHOD__ ) { if ( !$this->mTrxLevel ) { @@ -3481,7 +3480,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Issues the ROLLBACK command to the database server. * * @see DatabaseBase::rollback() - * @param type $fname + * @param string $fname */ protected function doRollback( $fname ) { if ( $this->mTrxLevel ) { @@ -3498,12 +3497,12 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * The table names passed to this function shall not be quoted (this * function calls addIdentifierQuotes when needed). * - * @param string $oldName name of table whose structure should be copied - * @param string $newName name of table to be created - * @param $temporary Boolean: whether the new table should be temporary - * @param string $fname calling function name + * @param string $oldName Name of table whose structure should be copied + * @param string $newName Name of table to be created + * @param bool $temporary Whether the new table should be temporary + * @param string $fname Calling function name * @throws MWException - * @return Boolean: true if operation was successful + * @return bool True if operation was successful */ public function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ @@ -3516,7 +3515,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * List all tables on the database * * @param string $prefix Only show tables with this prefix, e.g. mw_ - * @param string $fname calling function name + * @param string $fname Calling function name * @throws MWException */ function listTables( $prefix = null, $fname = __METHOD__ ) { @@ -3549,7 +3548,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Differentiates between a TABLE and a VIEW * - * @param $name string: Name of the database-structure to test. + * @param string $name Name of the database-structure to test. * @throws MWException * @since 1.22 */ @@ -3564,7 +3563,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * The result is unquoted, and needs to be passed through addQuotes() * before it can be included in raw SQL. * - * @param $ts string|int + * @param string|int $ts * * @return string */ @@ -3581,7 +3580,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * The result is unquoted, and needs to be passed through addQuotes() * before it can be included in raw SQL. * - * @param $ts string|int + * @param string|int $ts * * @return string */ @@ -3604,8 +3603,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * callers, so this is unnecessary in external code. For compatibility with * old code, ResultWrapper objects are passed through unaltered. * - * @param $result bool|ResultWrapper - * + * @param bool|ResultWrapper|resource $result * @return bool|ResultWrapper */ public function resultObject( $result ) { @@ -3658,7 +3656,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * don't allow simple quoted strings to be inserted. To insert into such * a field, pass the data through this function before passing it to * DatabaseBase::insert(). - * @param $b string + * + * @param string $b * @return string */ public function encodeBlob( $b ) { @@ -3669,7 +3668,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Some DBMSs return a special placeholder object representing blob fields * in result objects. Pass the object through this function to return the * original string. - * @param $b string + * + * @param string $b * @return string */ public function decodeBlob( $b ) { @@ -3683,7 +3683,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * full-wiki dumps, where a single query reads out over * hours or days. * - * @param $options Array + * @param array $options * @return void */ public function setSessionOptions( array $options ) { @@ -3700,9 +3700,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @param bool|callable $resultCallback Optional function called for each MySQL result * @param bool|string $fname Calling function name or false if name should be * generated dynamically using $filename - * @param bool|callable $inputCallback Callback: Optional function called - * for each complete line sent - * @throws MWException + * @param bool|callable $inputCallback Optional function called for each + * complete line sent * @throws Exception|MWException * @return bool|string */ @@ -3739,7 +3738,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * it fails back to MySQL if no DB-specific patch can be found * * @param string $patch The name of the patch, like patch-something.sql - * @return String Full path to patch file + * @return string Full path to patch file */ public function patchPath( $patch ) { global $IP; @@ -3757,7 +3756,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * ones in $GLOBALS. If an array is set here, $GLOBALS will not be used at * all. If it's set to false, $GLOBALS will be used. * - * @param bool|array $vars mapping variable name to value. + * @param bool|array $vars Mapping variable name to value. */ public function setSchemaVars( $vars ) { $this->mSchemaVars = $vars; @@ -3769,11 +3768,11 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Returns true on success, error string or exception on failure (depending * on object's error ignore settings). * - * @param $fp Resource: File handle - * @param $lineCallback Callback: Optional function called before reading each query - * @param $resultCallback Callback: Optional function called for each MySQL result + * @param resource $fp File handle + * @param bool|callable $lineCallback Optional function called before reading each query + * @param bool|callable $resultCallback Optional function called for each MySQL result * @param string $fname Calling function name - * @param $inputCallback Callback: Optional function called for each complete query sent + * @param bool|callable $inputCallback Optional function called for each complete query sent * @return bool|string */ public function sourceStream( $fp, $lineCallback = false, $resultCallback = false, @@ -3832,7 +3831,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * @param string $sql SQL assembled so far * @param string $newLine New line about to be added to $sql - * @return Bool Whether $newLine contains end of the statement + * @return bool Whether $newLine contains end of the statement */ public function streamStatementEnd( &$sql, &$newLine ) { if ( $this->delimiter ) { @@ -3861,7 +3860,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * table options its use should be avoided. * * @param string $ins SQL statement to replace variables in - * @return String The new SQL statement with variables replaced + * @return string The new SQL statement with variables replaced */ protected function replaceSchemaVars( $ins ) { $vars = $this->getSchemaVars(); @@ -3880,8 +3879,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Replace variables in sourced SQL * - * @param $ins string - * + * @param string $ins * @return string */ protected function replaceVars( $ins ) { @@ -3927,8 +3925,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Table name callback * - * @param $matches array - * + * @param array $matches * @return string */ protected function tableNameCallback( $matches ) { @@ -3938,8 +3935,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Index name callback * - * @param $matches array - * + * @param array $matches * @return string */ protected function indexNameCallback( $matches ) { @@ -3949,9 +3945,9 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Check to see if a named lock is available. This is non-blocking. * - * @param string $lockName name of lock to poll - * @param string $method name of method calling us - * @return Boolean + * @param string $lockName Name of lock to poll + * @param string $method Name of method calling us + * @return bool * @since 1.20 */ public function lockIsFree( $lockName, $method ) { @@ -3964,10 +3960,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Abstracted from Filestore::lock() so child classes can implement for * their own needs. * - * @param string $lockName name of lock to aquire - * @param string $method name of method calling us - * @param $timeout Integer: timeout - * @return Boolean + * @param string $lockName Name of lock to aquire + * @param string $method Name of method calling us + * @param int $timeout + * @return bool */ public function lock( $lockName, $method, $timeout = 5 ) { return true; @@ -3990,11 +3986,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Lock specific tables * - * @param array $read of tables to lock for read access - * @param array $write of tables to lock for write access - * @param string $method name of caller + * @param array $read Array of tables to lock for read access + * @param array $write Array of tables to lock for write access + * @param string $method Name of caller * @param bool $lowPriority Whether to indicate writes to be LOW PRIORITY - * * @return bool */ public function lockTables( $read, $write, $method, $lowPriority = true ) { @@ -4004,8 +3999,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Unlock specific tables * - * @param string $method the caller - * + * @param string $method The caller * @return bool */ public function unlockTables( $method ) { @@ -4014,8 +4008,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { /** * Delete a table - * @param $tableName string - * @param $fName string + * @param string $tableName + * @param string $fName * @return bool|ResultWrapper * @since 1.18 */ @@ -4035,7 +4029,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Get search engine class. All subclasses of this need to implement this * if they wish to use searching. * - * @return String + * @return string */ public function getSearchEngine() { return 'SearchEngineDummy'; @@ -4046,7 +4040,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * keyword for timestamps in PostgreSQL, and works with CHAR(14) as well * because "i" sorts after all numbers. * - * @return String + * @return string */ public function getInfinity() { return 'infinity'; @@ -4056,7 +4050,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Encode an expiry time into the DBMS dependent format * * @param string $expiry timestamp for expiry, or the 'infinity' string - * @return String + * @return string */ public function encodeExpiry( $expiry ) { return ( $expiry == '' || $expiry == 'infinity' || $expiry == $this->getInfinity() ) @@ -4068,8 +4062,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * Decode an expiry time into a DBMS independent format * * @param string $expiry DB timestamp field value for expiry - * @param $format integer: TS_* constant, defaults to TS_MW - * @return String + * @param int $format TS_* constant, defaults to TS_MW + * @return string */ public function decodeExpiry( $expiry, $format = TS_MW ) { return ( $expiry == '' || $expiry == $this->getInfinity() ) @@ -4083,7 +4077,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * * This is a MySQL-specific feature. * - * @param $value Mixed: true for allow, false for deny, or "default" to + * @param bool|string $value True for allow, false for deny, or "default" to * restore the initial value */ public function setBigSelects( $value = true ) { diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php index a314605bd8..b4c73651d9 100644 --- a/includes/db/DatabaseError.php +++ b/includes/db/DatabaseError.php @@ -26,14 +26,12 @@ * @ingroup Database */ class DBError extends MWException { - /** - * @var DatabaseBase - */ + /** @var DatabaseBase */ public $db; /** * Construct a database error - * @param $db DatabaseBase object which threw the error + * @param DatabaseBase $db Object which threw the error * @param string $error A simple error message to be used for debugging */ function __construct( DatabaseBase $db = null, $error ) { @@ -90,8 +88,13 @@ class DBError extends MWException { * @ingroup Database */ class DBConnectionError extends DBError { + /** @var string Error text */ public $error; + /** + * @param DatabaseBase $db Object throwing the error + * @param string $error Error text + */ function __construct( DatabaseBase $db = null, $error = 'unknown error' ) { $msg = 'DB connection error'; @@ -114,9 +117,11 @@ class DBConnectionError extends DBError { } /** - * @param $key - * @param $fallback - * @return string + * @param string $key + * @param string $fallback Unescaped alternative error text in case the + * message cache cannot be used. Can contain parameters as in regular + * messages, that should be passed as additional parameters. + * @return string Unprocessed plain error text with parameters replaced */ function msg( $key, $fallback /*[, params...] */ ) { global $wgLang; @@ -141,7 +146,7 @@ class DBConnectionError extends DBError { } /** - * @return string + * @return string Safe HTML */ function getHTML() { global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors; @@ -192,6 +197,11 @@ class DBConnectionError extends DBError { } } + /** + * Output the exception report using HTML. + * + * @return void + */ public function reportHTML() { global $wgUseFileCache; @@ -307,11 +317,11 @@ class DBQueryError extends DBError { public $error, $errno, $sql, $fname; /** - * @param $db DatabaseBase - * @param $error string - * @param $errno int|string - * @param $sql string - * @param $fname string + * @param DatabaseBase $db + * @param string $error + * @param int|string $errno + * @param string $sql + * @param string $fname */ function __construct( DatabaseBase $db, $error, $errno, $sql, $fname ) { $message = "A database error has occurred. Did you forget to run " . @@ -329,7 +339,7 @@ class DBQueryError extends DBError { } /** - * @return boolean + * @return bool */ function isLoggable() { // Don't send to the exception log, already in dberror log @@ -391,7 +401,7 @@ class DBQueryError extends DBError { * sites using this option probably don't care much about "security by obscurity". Of course, * if $wgShowSQLErrors is true, the SQL query *is* shown. * - * @return array: Keys are message keys; values are arrays of arguments for Html::element(). + * @return array Keys are message keys; values are arrays of arguments for Html::element(). * Array will be empty if users are not allowed to see any of these details at all. */ protected function getTechnicalDetails() { @@ -416,7 +426,7 @@ class DBQueryError extends DBError { /** * @param string $key Message key - * @return string: English message text + * @return string English message text */ private function getFallbackMessage( $key ) { $messages = array( diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index 3a89cd50c8..ab23cd0176 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -159,6 +159,11 @@ class DatabaseMssql extends DatabaseBase { return sqlsrv_close( $this->mConn ); } + /** + * @param string $sql + * @return bool|MssqlResult + * @throws DBUnexpectedError + */ protected function doQuery( $sql ) { wfDebug( "SQL: [$sql]\n" ); $this->offset = 0; @@ -213,6 +218,9 @@ class DatabaseMssql extends DatabaseBase { return $res; } + /** + * @param mixed|ResultWrapper $res + */ function freeResult( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -220,6 +228,10 @@ class DatabaseMssql extends DatabaseBase { $res->free(); } + /** + * @param ResultWrapper|stdClass $res + * @return stdClass + */ function fetchObject( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -229,6 +241,9 @@ class DatabaseMssql extends DatabaseBase { return $row; } + /** + * @return string + */ function getErrors() { $strRet = ''; $retErrors = sqlsrv_errors( SQLSRV_ERR_ALL ); @@ -245,6 +260,10 @@ class DatabaseMssql extends DatabaseBase { return $strRet; } + /** + * @param resource $res + * @return Blob + */ function fetchRow( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -254,6 +273,10 @@ class DatabaseMssql extends DatabaseBase { return $row; } + /** + * @param mixed $res + * @return int + */ function numRows( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -286,6 +309,11 @@ class DatabaseMssql extends DatabaseBase { return $this->mInsertId; } + /** + * @param mixed $res + * @param int $row + * @return bool + */ function dataSeek( $res, $row ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -318,16 +346,16 @@ class DatabaseMssql extends DatabaseBase { /** * SELECT wrapper * - * @param $table Mixed: array or string, table name(s) (prefix auto-added) - * @param $vars Mixed: array or string, field name(s) to be retrieved - * @param $conds Mixed: array or string, condition(s) for WHERE - * @param $fname String: calling function name (use __METHOD__) for logs/profiling - * @param array $options associative array of options (e.g. + * @param mixed $table Array or string, table name(s) (prefix auto-added) + * @param mixed $vars Array or string, field name(s) to be retrieved + * @param mixed $conds Array or string, condition(s) for WHERE + * @param string $fname Calling function name (use __METHOD__) for logs/profiling + * @param array $options Associative array of options (e.g. * array('GROUP BY' => 'page_title')), see Database::makeSelectOptions * code for list of supported stuff - * @param $join_conds Array: Associative array of table join conditions + * @param array $join_conds Associative array of table join conditions * (optional) (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) - * @return Mixed: database result resource (feed to Database::fetchObject + * @return mixed Database result resource (feed to Database::fetchObject * or whatever), or false on failure */ function select( $table, $vars, $conds = '', $fname = __METHOD__, @@ -348,15 +376,15 @@ class DatabaseMssql extends DatabaseBase { /** * SELECT wrapper * - * @param $table Mixed: Array or string, table name(s) (prefix auto-added) - * @param $vars Mixed: Array or string, field name(s) to be retrieved - * @param $conds Mixed: Array or string, condition(s) for WHERE - * @param $fname String: Calling function name (use __METHOD__) for logs/profiling + * @param mixed $table Array or string, table name(s) (prefix auto-added) + * @param mixed $vars Array or string, field name(s) to be retrieved + * @param mixed $conds Array or string, condition(s) for WHERE + * @param string $fname Calling function name (use __METHOD__) for logs/profiling * @param array $options Associative array of options (e.g. array('GROUP BY' => 'page_title')), - * see Database::makeSelectOptions code for list of supported stuff - * @param $join_conds Array: Associative array of table join conditions (optional) - * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) - * @return string, the SQL text + * see Database::makeSelectOptions code for list of supported stuff + * @param array $join_conds Associative array of table join conditions (optional) + * (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) + * @return string The SQL text */ function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() @@ -374,6 +402,11 @@ class DatabaseMssql extends DatabaseBase { * This is not necessarily an accurate estimate, so use sparingly * Returns -1 if count cannot be found * Takes same arguments as Database::select() + * @param string $table + * @param string $vars + * @param string $conds + * @param string $fname + * @param array $options * @return int */ function estimateRowCount( $table, $vars = '*', $conds = '', @@ -397,6 +430,9 @@ class DatabaseMssql extends DatabaseBase { /** * Returns information about an index * If errors are explicitly ignored, returns NULL on failure + * @param string $table + * @param string $index + * @param string $fname * @return array|bool|null */ function indexInfo( $table, $index, $fname = __METHOD__ ) { @@ -607,6 +643,7 @@ class DatabaseMssql extends DatabaseBase { throw new DBQueryError( $this, $this->getErrors(), $this->lastErrno(), /*$sql*/ '', $fname ); } elseif ( $ret != null ) { // remember number of rows affected + // @todo FIXME: $ret type does not appear to be a resource $this->mAffectedRows = sqlsrv_rows_affected( $ret ); return $ret; @@ -617,7 +654,8 @@ class DatabaseMssql extends DatabaseBase { /** * Return the next in a sequence, save the value for retrieval via insertId() - * @return + * @param string $seqName + * @return int|null */ function nextSequenceValue( $seqName ) { if ( !$this->tableExists( 'sequence_' . $seqName ) ) { @@ -639,7 +677,8 @@ class DatabaseMssql extends DatabaseBase { /** * Return the current value of a sequence. Assumes it has ben nextval'ed in this session. - * @return + * @param string $seqName + * @return int|null */ function currentSequenceValue( $seqName ) { $ret = sqlsrv_query( $this->mConn, "SELECT TOP 1 id FROM [sequence_$seqName] ORDER BY id DESC" ); @@ -653,7 +692,11 @@ class DatabaseMssql extends DatabaseBase { } } - # Returns the size of a text field, or -1 for "unlimited" + /** + * @param string $table + * @param string $field + * @return int Returns the size of a text field, or -1 for "unlimited" + */ function textFieldSize( $table, $field ) { $table = $this->tableName( $table ); $sql = "SELECT CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.Columns @@ -671,10 +714,11 @@ class DatabaseMssql extends DatabaseBase { /** * Construct a LIMIT query with optional offset * This is used for query pages - * $sql string SQL query we will append the limit too - * $limit integer the SQL limit - * $offset integer the SQL offset (default false) - * @return mixed|string + * + * @param string $sql SQL query we will append the limit too + * @param int $limit The SQL limit + * @param bool|int $offset The SQL offset (default false) + * @return array|string */ function limitResult( $sql, $limit, $offset = false ) { if ( $offset === false || $offset == 0 ) { @@ -696,11 +740,16 @@ class DatabaseMssql extends DatabaseBase { } } - // If there is a limit clause, parse it, strip it, and pass the remaining - // SQL through limitResult() with the appropriate parameters. Not the - // prettiest solution, but better than building a whole new parser. This - // exists becase there are still too many extensions that don't use dynamic - // sql generation. + /** + * If there is a limit clause, parse it, strip it, and pass the remaining + * SQL through limitResult() with the appropriate parameters. Not the + * prettiest solution, but better than building a whole new parser. This + * exists becase there are still too many extensions that don't use dynamic + * sql generation. + * + * @param string $sql + * @return array|mixed|string + */ function LimitToTopN( $sql ) { // Matches: LIMIT {[offset,] row_count | row_count OFFSET offset} $pattern = '/\bLIMIT\s+((([0-9]+)\s*,\s*)?([0-9]+)(\s+OFFSET\s+([0-9]+))?)/i'; @@ -721,12 +770,18 @@ class DatabaseMssql extends DatabaseBase { return $sql; } + /** + * Timestamp in ISO 8601 format with no timezone: 1986-02-09T20:00:00Z + * + * @param int $ts Timestamp + * @return bool|string The same date in ISO 8601 format with no timezone or false + */ function timestamp( $ts = 0 ) { return wfTimestamp( TS_ISO_8601, $ts ); } /** - * @return string wikitext of a link to the server software's web site + * @return string Wikitext of a link to the server software's web site */ public function getSoftwareLink() { return "[http://www.microsoft.com/sql/ MS SQL Server]"; @@ -745,6 +800,12 @@ class DatabaseMssql extends DatabaseBase { return $version; } + /** + * @param string $table + * @param string $fname + * @param bool $schema + * @return bool + */ function tableExists( $table, $fname = __METHOD__, $schema = false ) { $res = sqlsrv_query( $this->mConn, "SELECT * FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_name = '$table'" ); @@ -762,6 +823,9 @@ class DatabaseMssql extends DatabaseBase { /** * Query whether a given column exists in the mediawiki schema + * @param string $table + * @param string $field + * @param string $fname * @return bool */ function fieldExists( $table, $field, $fname = __METHOD__ ) { @@ -826,7 +890,7 @@ class DatabaseMssql extends DatabaseBase { * Escapes a identifier for use inm SQL. * Throws an exception if it is invalid. * Reference: http://msdn.microsoft.com/en-us/library/aa224033%28v=SQL.80%29.aspx - * @param $identifier + * @param string $identifier * @throws MWException * @return string */ @@ -916,7 +980,9 @@ class DatabaseMssql extends DatabaseBase { } /** - * @private + * @param array $tables + * @param array $use_index + * @param array $join_conds * @return string */ function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) { @@ -980,11 +1046,9 @@ class DatabaseMssql extends DatabaseBase { } /** - * @private - * * @param array $options an associative array of options to be turned into - * an SQL query, valid keys are listed in the function. - * @return Array + * an SQL query, valid keys are listed in the function. + * @return array */ function makeSelectOptions( $options ) { $tailOpts = ''; @@ -1085,7 +1149,9 @@ class MssqlField implements Field { * @ingroup Database */ class MssqlResult { - + /** + * @param bool|resource $queryresult + */ public function __construct( $queryresult = false ) { $this->mCursor = 0; $this->mRows = array(); @@ -1108,6 +1174,11 @@ class MssqlResult { sqlsrv_free_stmt( $queryresult ); } + /** + * @param array $array + * @param stdClass $obj + * @return stdClass + */ private function array_to_obj( $array, &$obj ) { foreach ( $array as $key => $value ) { if ( is_array( $value ) ) { diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index b600d94846..dc4a67dff3 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -29,8 +29,8 @@ */ class DatabaseMysql extends DatabaseMysqlBase { /** - * @param $sql string - * @return resource + * @param string $sql + * @return resource False on error */ protected function doQuery( $sql ) { if ( $this->bufferResults() ) { @@ -42,6 +42,11 @@ class DatabaseMysql extends DatabaseMysqlBase { return $ret; } + /** + * @param string $realServer + * @return bool|resource MySQL Database connection or false on failure to connect + * @throws DBConnectionError + */ protected function mysqlConnect( $realServer ) { # Fail now # Otherwise we get a suppressed fatal error, which is very hard to track down @@ -84,6 +89,7 @@ class DatabaseMysql extends DatabaseMysqlBase { } /** + * @param string $charset * @return bool */ protected function mysqlSetCharset( $charset ) { @@ -127,7 +133,7 @@ class DatabaseMysql extends DatabaseMysqlBase { } /** - * @param $db + * @param string $db * @return bool */ function selectDB( $db ) { diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index 12fee941c3..587d72718b 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -41,12 +41,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $server string - * @param $user string - * @param $password string - * @param $dbName string + * @param string $server + * @param string $user + * @param string $password + * @param string $dbName + * @throws Exception|DBConnectionError * @return bool - * @throws DBConnectionError */ function open( $server, $user, $password, $dbName ) { global $wgAllDBsAreLocalhost, $wgSQLMode; @@ -155,7 +155,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Open a connection to a MySQL server * - * @param $realServer string + * @param string $realServer * @return mixed Raw connection * @throws DBConnectionError */ @@ -170,7 +170,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { abstract protected function mysqlSetCharset( $charset ); /** - * @param $res ResultWrapper + * @param ResultWrapper|resource $res * @throws DBUnexpectedError */ function freeResult( $res ) { @@ -188,14 +188,14 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Free result memory * - * @param $res Raw result + * @param resource $res Raw result * @return bool */ abstract protected function mysqlFreeResult( $res ); /** - * @param $res ResultWrapper - * @return object|bool + * @param ResultWrapper|resource $res + * @return stdClass|bool * @throws DBUnexpectedError */ function fetchObject( $res ) { @@ -224,13 +224,13 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Fetch a result row as an object * - * @param $res Raw result + * @param resource $res Raw result * @return stdClass */ abstract protected function mysqlFetchObject( $res ); /** - * @param $res ResultWrapper + * @param ResultWrapper|resource $res * @return array|bool * @throws DBUnexpectedError */ @@ -260,14 +260,14 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Fetch a result row as an associative and numeric array * - * @param $res Raw result + * @param resource $res Raw result * @return array */ abstract protected function mysqlFetchArray( $res ); /** * @throws DBUnexpectedError - * @param $res ResultWrapper + * @param ResultWrapper|resource $res * @return int */ function numRows( $res ) { @@ -289,13 +289,13 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get number of rows in result * - * @param $res Raw result + * @param resource $res Raw result * @return int */ abstract protected function mysqlNumRows( $res ); /** - * @param $res ResultWrapper + * @param ResultWrapper|resource $res * @return int */ function numFields( $res ) { @@ -309,13 +309,13 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get number of fields in result * - * @param $res Raw result + * @param resource $res Raw result * @return int */ abstract protected function mysqlNumFields( $res ); /** - * @param $res ResultWrapper + * @param ResultWrapper|resource $res * @param $n int * @return string */ @@ -330,7 +330,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get the name of the specified field in a result * - * @param $res Raw result + * @param ResultWrapper|resource $res * @param $n int * @return string */ @@ -338,7 +338,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * mysql_field_type() wrapper - * @param $res + * @param ResultWrapper|resource $res * @param $n int * @return string */ @@ -353,15 +353,15 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get the type of the specified field in a result * - * @param $res Raw result - * @param $n int + * @param ResultWrapper|resource $res + * @param int $n * @return string */ abstract protected function mysqlFieldType( $res, $n ); /** - * @param $res ResultWrapper - * @param $row + * @param ResultWrapper|resource $res + * @param int $row * @return bool */ function dataSeek( $res, $row ) { @@ -375,8 +375,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Move internal result pointer * - * @param $res Raw result - * @param $row int + * @param ResultWrapper|resource $res + * @param int $row * @return bool */ abstract protected function mysqlDataSeek( $res, $row ); @@ -406,16 +406,16 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Returns the text of the error message from previous MySQL operation * - * @param $conn Raw connection + * @param resource $conn Raw connection * @return string */ abstract protected function mysqlError( $conn = null ); /** - * @param $table string - * @param $uniqueIndexes - * @param $rows array - * @param $fname string + * @param string $table + * @param array $uniqueIndexes + * @param array $rows + * @param string $fname * @return ResultWrapper */ function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) { @@ -427,12 +427,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * Returns estimated count, based on EXPLAIN output * Takes same arguments as Database::select() * - * @param $table string|array - * @param $vars string|array - * @param $conds string|array - * @param $fname string - * @param $options string|array - * @return int + * @param string|array $table + * @param string|array $vars + * @param string|array $conds + * @param string $fname + * @param string|array $options + * @return bool|int */ public function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() @@ -455,8 +455,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $table string - * @param $field string + * @param string $table + * @param string $field * @return bool|MySQLField */ function fieldInfo( $table, $field ) { @@ -479,8 +479,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get column information from a result * - * @param $res Raw result - * @param $n int + * @param resource $res Raw result + * @param int $n * @return stdClass */ abstract protected function mysqlFetchField( $res, $n ); @@ -489,9 +489,9 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * Get information about an index into an object * Returns false if the index does not exist * - * @param $table string - * @param $index string - * @param $fname string + * @param string $table + * @param string $index + * @param string $fname * @return bool|array|null False or null on failure */ function indexInfo( $table, $index, $fname = __METHOD__ ) { @@ -520,8 +520,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $s string - * + * @param string $s * @return string */ function strencode( $s ) { @@ -538,8 +537,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes". * - * @param $s string - * + * @param string $s * @return string */ public function addIdentifierQuotes( $s ) { @@ -549,7 +547,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $name string + * @param string $name * @return bool */ public function isQuotedIdentifier( $name ) { @@ -659,10 +657,10 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Wait for the slave to catch up to a given master position. - * @TODO: return values for this and base class are rubbish + * @todo Return values for this and base class are rubbish * - * @param $pos DBMasterPos object - * @param $timeout Integer: the maximum number of seconds to wait for synchronisation + * @param DBMasterPos|MySQLMasterPos $pos + * @param int $timeout The maximum number of seconds to wait for synchronisation * @return bool|string */ function masterPosWait( DBMasterPos $pos, $timeout ) { @@ -745,7 +743,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $index + * @param string $index * @return string */ function useIndexClause( $index ) { @@ -767,7 +765,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $options array + * @param array $options */ public function setSessionOptions( array $options ) { if ( isset( $options['connTimeout'] ) ) { @@ -777,6 +775,11 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } } + /** + * @param string $sql + * @param string $newLine + * @return bool + */ public function streamStatementEnd( &$sql, &$newLine ) { if ( strtoupper( substr( $newLine, 0, 9 ) ) == 'DELIMITER' ) { preg_match( '/^DELIMITER\s+(\S+)/', $newLine, $m ); @@ -792,7 +795,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * * @param string $lockName name of lock to poll * @param string $method name of method calling us - * @return Boolean + * @return bool * @since 1.20 */ public function lockIsFree( $lockName, $method ) { @@ -804,9 +807,9 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $lockName string - * @param $method string - * @param $timeout int + * @param string $lockName + * @param string $method + * @param int $timeout * @return bool */ public function lock( $lockName, $method, $timeout = 5 ) { @@ -826,8 +829,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * FROM MYSQL DOCS: * http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock - * @param $lockName string - * @param $method string + * @param string $lockName + * @param string $method * @return bool */ public function unlock( $lockName, $method ) { @@ -839,10 +842,10 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $read array - * @param $write array - * @param $method string - * @param $lowPriority bool + * @param array $read + * @param array $write + * @param string $method + * @param bool $lowPriority * @return bool */ public function lockTables( $read, $write, $method, $lowPriority = true ) { @@ -864,7 +867,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $method string + * @param string $method * @return bool */ public function unlockTables( $method ) { @@ -877,7 +880,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * Get search engine class. All subclasses of this * need to implement this if they wish to use searching. * - * @return String + * @return string */ public function getSearchEngine() { return 'SearchMySQL'; @@ -885,7 +888,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * @param bool $value - * @return mixed + * @return mixed null|bool|ResultWrapper */ public function setBigSelects( $value = true ) { if ( $value === 'default' ) { @@ -1009,10 +1012,11 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } /** - * @param $oldName - * @param $newName - * @param $temporary bool - * @param $fname string + * @param string $oldName + * @param string $newName + * @param bool $temporary + * @param string $fname + * @return bool */ function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) { $tmp = $temporary ? 'TEMPORARY ' : ''; @@ -1026,7 +1030,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { * List all tables on the database * * @param string $prefix Only show tables with this prefix, e.g. mw_ - * @param string $fname calling function name + * @param string $fname Calling function name * @return array */ function listTables( $prefix = null, $fname = __METHOD__ ) { @@ -1077,7 +1081,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Get status information from SHOW STATUS in an associative array * - * @param $which string + * @param string $which * @return array */ function getMysqlStatus( $which = "%" ) { @@ -1133,7 +1137,8 @@ abstract class DatabaseMysqlBase extends DatabaseBase { /** * Differentiates between a TABLE and a VIEW. * - * @param $name string: Name of the TABLE/VIEW to test + * @param string $name Name of the TABLE/VIEW to test + * @param string $prefix * @return bool * @since 1.22 */ @@ -1216,7 +1221,11 @@ class MySQLField implements Field { } class MySQLMasterPos implements DBMasterPos { - var $file, $pos; + /** @var string */ + public $file; + + /** @var int */ + private $pos; function __construct( $file, $pos ) { $this->file = $file; diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php index d0c19fa1e2..d41f3e4c69 100644 --- a/includes/db/DatabaseMysqli.php +++ b/includes/db/DatabaseMysqli.php @@ -30,7 +30,7 @@ */ class DatabaseMysqli extends DatabaseMysqlBase { /** - * @param $sql string + * @param string $sql * @return resource */ protected function doQuery( $sql ) { @@ -43,6 +43,11 @@ class DatabaseMysqli extends DatabaseMysqlBase { return $ret; } + /** + * @param string $realServer + * @return bool|mysqli + * @throws DBConnectionError + */ protected function mysqlConnect( $realServer ) { global $wgDBmysql5; # Fail now @@ -93,6 +98,7 @@ class DatabaseMysqli extends DatabaseMysqlBase { } /** + * @param string $charset * @return bool */ protected function mysqlSetCharset( $charset ) { @@ -136,7 +142,7 @@ class DatabaseMysqli extends DatabaseMysqlBase { } /** - * @param $db + * @param string $db * @return bool */ function selectDB( $db ) { @@ -152,12 +158,20 @@ class DatabaseMysqli extends DatabaseMysqlBase { return $this->mConn->server_info; } + /** + * @param mysqli $res + * @return bool + */ protected function mysqlFreeResult( $res ) { $res->free_result(); return true; } + /** + * @param mysqli $res + * @return bool + */ protected function mysqlFetchObject( $res ) { $object = $res->fetch_object(); if ( $object === null ) { @@ -167,6 +181,10 @@ class DatabaseMysqli extends DatabaseMysqlBase { return $object; } + /** + * @param mysqli $res + * @return bool + */ protected function mysqlFetchArray( $res ) { $array = $res->fetch_array(); if ( $array === null ) { @@ -176,14 +194,27 @@ class DatabaseMysqli extends DatabaseMysqlBase { return $array; } + /** + * @param mysqli $res + * @return mixed + */ protected function mysqlNumRows( $res ) { return $res->num_rows; } + /** + * @param mysqli $res + * @return mixed + */ protected function mysqlNumFields( $res ) { return $res->field_count; } + /** + * @param mysqli $res + * @param int $n + * @return mixed + */ protected function mysqlFetchField( $res, $n ) { $field = $res->fetch_field_direct( $n ); $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG; @@ -195,21 +226,40 @@ class DatabaseMysqli extends DatabaseMysqlBase { return $field; } + /** + * @param resource|ResultWrapper $res + * @param int $n + * @return mixed + */ protected function mysqlFieldName( $res, $n ) { $field = $res->fetch_field_direct( $n ); return $field->name; } + /** + * @param resource|ResultWrapper $res + * @param int $n + * @return mixed + */ protected function mysqlFieldType( $res, $n ) { $field = $res->fetch_field_direct( $n ); return $field->type; } + /** + * @param resource|ResultWrapper $res + * @param int $row + * @return mixed + */ protected function mysqlDataSeek( $res, $row ) { return $res->data_seek( $row ); } + /** + * @param mysqli $conn Optional connection object + * @return string + */ protected function mysqlError( $conn = null ) { if ( $conn === null ) { return mysqli_connect_error(); @@ -218,6 +268,11 @@ class DatabaseMysqli extends DatabaseMysqlBase { } } + /** + * Escapes special characters in a string for use in an SQL statement + * @param string $s + * @return string + */ protected function mysqlRealEscapeString( $s ) { return $this->mConn->real_escape_string( $s ); } diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 3336d1efd3..bb901b1999 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -50,8 +50,8 @@ class ORAResult { } /** - * @param $db DatabaseBase - * @param $stmt + * @param DatabaseBase $db + * @param resource $stmt A valid OCI statement identifier * @param bool $unique */ function __construct( &$db, $stmt, $unique = false ) { @@ -442,6 +442,10 @@ class DatabaseOracle extends DatabaseBase { return $this->query( $sql, $fname, true ); } + /** + * Frees resources associated with the LOB descriptor + * @param ResultWrapper|resource $res + */ function freeResult( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -450,6 +454,10 @@ class DatabaseOracle extends DatabaseBase { $res->free(); } + /** + * @param ResultWrapper|stdClass $res + * @return mixed + */ function fetchObject( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -494,6 +502,10 @@ class DatabaseOracle extends DatabaseBase { return $this->mInsertId; } + /** + * @param mixed $res + * @param int $row + */ function dataSeek( $res, $row ) { if ( $res instanceof ORAResult ) { $res->seek( $row ); @@ -529,6 +541,9 @@ class DatabaseOracle extends DatabaseBase { /** * Returns information about an index * If errors are explicitly ignored, returns NULL on failure + * @param string $table + * @param string $index + * @param string $fname * @return bool */ function indexInfo( $table, $index, $fname = __METHOD__ ) { @@ -603,6 +618,13 @@ class DatabaseOracle extends DatabaseBase { return $bind; } + /** + * @param string $table + * @param $row + * @param string $fname + * @return bool + * @throws DBUnexpectedError + */ private function insertOneRow( $table, $row, $fname ) { global $wgContLang; @@ -654,6 +676,7 @@ class DatabaseOracle extends DatabaseBase { return false; } } else { + /** @var OCI_Lob[] $lob */ if ( ( $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB ) ) === false ) { $e = oci_error( $stmt ); throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] ); @@ -822,7 +845,13 @@ class DatabaseOracle extends DatabaseBase { return ( isset( $this->sequenceData[$table] ) ) ? $this->sequenceData[$table] : false; } - # Returns the size of a text field, or -1 for "unlimited" + /** + * Returns the size of a text field, or -1 for "unlimited" + * + * @param string $table + * @param string $field + * @return mixed + */ function textFieldSize( $table, $field ) { $fieldInfoData = $this->fieldInfo( $table, $field ); @@ -916,6 +945,10 @@ class DatabaseOracle extends DatabaseBase { /** * Return aggregated value function call + * + * @param $valuedata + * @param string $valuename + * @return mixed */ public function aggregateValue( $valuedata, $valuename = 'value' ) { return $valuedata; @@ -960,6 +993,9 @@ class DatabaseOracle extends DatabaseBase { /** * Query whether a given index exists + * @param string $table + * @param string $index + * @param string $fname * @return bool */ function indexExists( $table, $index, $fname = __METHOD__ ) { @@ -981,6 +1017,8 @@ class DatabaseOracle extends DatabaseBase { /** * Query whether a given table exists (in the given schema, or the default mw one if not given) + * @param string $table + * @param string $fname * @return bool */ function tableExists( $table, $fname = __METHOD__ ) { @@ -1006,8 +1044,8 @@ class DatabaseOracle extends DatabaseBase { * For internal calls. Use fieldInfo for normal usage. * Returns false if the field doesn't exist * - * @param $table Array - * @param $field String + * @param array|string $table + * @param string $field * @return ORAField|ORAResult */ private function fieldInfoMulti( $table, $field ) { @@ -1064,8 +1102,8 @@ class DatabaseOracle extends DatabaseBase { /** * @throws DBUnexpectedError - * @param $table - * @param $field + * @param string $table + * @param string $field * @return ORAField */ function fieldInfo( $table, $field ) { @@ -1100,7 +1138,16 @@ class DatabaseOracle extends DatabaseBase { } } - /* defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}'; */ + /** + * defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}'; + * + * @param resource $fp + * @param bool|string $lineCallback + * @param bool|callable $resultCallback + * @param string $fname + * @param bool|callable $inputCallback + * @return bool|string + */ function sourceStream( $fp, $lineCallback = false, $resultCallback = false, $fname = __METHOD__, $inputCallback = false ) { $cmd = ''; @@ -1275,10 +1322,8 @@ class DatabaseOracle extends DatabaseBase { * Returns an optional USE INDEX clause to go after the table, and a * string to go at the end of the query * - * @private - * - * @param array $options an associative array of options to be turned into - * an SQL query, valid keys are listed in the function. + * @param array $options An associative array of options to be turned into + * an SQL query, valid keys are listed in the function. * @return array */ function makeSelectOptions( $options ) { @@ -1347,6 +1392,15 @@ class DatabaseOracle extends DatabaseBase { return parent::delete( $table, $conds, $fname ); } + /** + * @param string $table + * @param array $values + * @param array $conds + * @param string $fname + * @param array $options + * @return bool + * @throws DBUnexpectedError + */ function update( $table, $values, $conds, $fname = __METHOD__, $options = array() ) { global $wgContLang; @@ -1485,4 +1539,4 @@ class DatabaseOracle extends DatabaseBase { public function getInfinity() { return '31-12-2030 12:00:00.000000'; } -} // end DatabaseOracle class +} diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 21a7bcf1e4..af48254ce7 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -26,9 +26,9 @@ class PostgresField implements Field { $has_default, $default; /** - * @param $db DatabaseBase - * @param $table - * @param $field + * @param DatabaseBase $db + * @param string $table + * @param string $field * @return null|PostgresField */ static function fromText( $db, $table, $field ) { @@ -216,13 +216,15 @@ class PostgresTransactionState { * @since 1.19 */ class SavepointPostgres { - /** - * Establish a savepoint within a transaction - */ + /** @var DatabaseBase Establish a savepoint within a transaction */ protected $dbw; protected $id; protected $didbegin; + /** + * @param DatabaseBase $dbw + * @param $id + */ public function __construct( $dbw, $id ) { $this->dbw = $dbw; $this->id = $id; @@ -362,7 +364,7 @@ class DatabasePostgres extends DatabaseBase { * @param string $user * @param string $password * @param string $dbName - * @throws DBConnectionError + * @throws DBConnectionError|Exception * @return DatabaseBase|null */ function open( $server, $user, $password, $dbName ) { @@ -450,7 +452,8 @@ class DatabasePostgres extends DatabaseBase { /** * Postgres doesn't support selectDB in the same way MySQL does. So if the * DB name doesn't match the open connection, open a new one - * @return + * @param string $db + * @return bool */ function selectDB( $db ) { if ( $this->mDBname !== $db ) { @@ -536,6 +539,10 @@ class DatabasePostgres extends DatabaseBase { return $this->query( $sql, $fname, true ); } + /** + * @param stdClass|ResultWrapper $res + * @throws DBUnexpectedError + */ function freeResult( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -548,6 +555,11 @@ class DatabasePostgres extends DatabaseBase { } } + /** + * @param ResultWrapper|stdClass $res + * @return stdClass + * @throws DBUnexpectedError + */ function fetchObject( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -629,6 +641,11 @@ class DatabasePostgres extends DatabaseBase { return $this->mInsertId; } + /** + * @param mixed $res + * @param int $row + * @return bool + */ function dataSeek( $res, $row ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -675,6 +692,12 @@ class DatabasePostgres extends DatabaseBase { * This is not necessarily an accurate estimate, so use sparingly * Returns -1 if count cannot be found * Takes same arguments as Database::select() + * + * @param string $table + * @param string $vars + * @param string $conds + * @param string $fname + * @param array $options * @return int */ function estimateRowCount( $table, $vars = '*', $conds = '', @@ -697,6 +720,10 @@ class DatabasePostgres extends DatabaseBase { /** * Returns information about an index * If errors are explicitly ignored, returns NULL on failure + * + * @param string $table + * @param string $index + * @param string $fname * @return bool|null */ function indexInfo( $table, $index, $fname = __METHOD__ ) { @@ -718,7 +745,9 @@ class DatabasePostgres extends DatabaseBase { * Returns is of attributes used in index * * @since 1.19 - * @return Array + * @param string $index + * @param bool|string $schema + * @return array */ function indexAttributes( $index, $schema = false ) { if ( $schema === false ) { @@ -796,11 +825,10 @@ __INDEXATTR__; * $args may be a single associative array, or an array of these with numeric keys, * for multi-row insert (Postgres version 8.2 and above only). * - * @param $table String: Name of the table to insert to. - * @param $args Array: Items to insert into the table. - * @param $fname String: Name of the function, for profiling - * @param string $options or Array. Valid options: IGNORE - * + * @param string $table Name of the table to insert to. + * @param array $args Items to insert into the table. + * @param string $fname Name of the function, for profiling + * @param array|string $options String or array. Valid options: IGNORE * @return bool Success of insert operation. IGNORE always returns true. */ function insert( $table, $args, $fname = __METHOD__, $options = array() ) { @@ -919,6 +947,14 @@ __INDEXATTR__; * $conds may be "*" to copy the whole table * srcTable may be an array of tables. * @todo FIXME: Implement this a little better (seperate select/insert)? + * + * @param string $destTable + * @param array|string $srcTable + * @param array $varMap + * @param array $conds + * @param string $fname + * @param array $insertOptions + * @param array $selectOptions * @return bool */ function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__, @@ -1019,7 +1055,7 @@ __INDEXATTR__; * Return the current value of a sequence. Assumes it has been nextval'ed in this session. * * @param string $seqName - * @return + * @return int */ function currentSequenceValue( $seqName ) { $safeseq = str_replace( "'", "''", $seqName ); @@ -1096,10 +1132,10 @@ __INDEXATTR__; * This should really be handled by PHP PostgreSQL module * * @since 1.19 - * @param $text string: postgreql array returned in a text form like {a,b} - * @param $output string - * @param $limit int - * @param $offset int + * @param string $text Postgreql array returned in a text form like {a,b} + * @param string $output + * @param int $limit + * @param int $offset * @return string */ function pg_array_parse( $text, &$output, $limit = false, $offset = 1 ) { @@ -1137,7 +1173,7 @@ __INDEXATTR__; } /** - * @return string wikitext of a link to the server software's web site + * @return string Wikitext of a link to the server software's web site */ public function getSoftwareLink() { return '[http://www.postgresql.org/ PostgreSQL]'; @@ -1184,7 +1220,7 @@ __INDEXATTR__; * Needs transaction * * @since 1.19 - * @return array how to search for table names schemas for the current user + * @return array How to search for table names schemas for the current user */ function getSearchPath() { $res = $this->query( "SHOW search_path", __METHOD__ ); @@ -1217,7 +1253,7 @@ __INDEXATTR__; * This will be also called by the installer after the schema is created * * @since 1.19 - * @param $desired_schema string + * @param string $desired_schema */ function determineCoreSchema( $desired_schema ) { $this->begin( __METHOD__ ); @@ -1281,6 +1317,9 @@ __INDEXATTR__; /** * Query whether a given relation exists (in the given schema, or the * default mw one if not given) + * @param string $table + * @param array|string $types + * @param bool|string $schema * @return bool */ function relationExists( $table, $types, $schema = false ) { @@ -1305,6 +1344,9 @@ __INDEXATTR__; /** * For backward compatibility, this function checks both tables and * views. + * @param string $table + * @param string $fname + * @param bool|string $schema * @return bool */ function tableExists( $table, $fname = __METHOD__, $schema = false ) { @@ -1368,6 +1410,7 @@ SQL; /** * Query whether a given schema exists. Returns true if it does, false if it doesn't. + * @param string $schema * @return bool */ function schemaExists( $schema ) { @@ -1379,6 +1422,7 @@ SQL; /** * Returns true if a given role (i.e. user) exists, false otherwise. + * @param string $roleName * @return bool */ function roleExists( $roleName ) { @@ -1394,6 +1438,8 @@ SQL; /** * pg_field_type() wrapper + * @param ResultWrapper|resource $res ResultWrapper or PostgreSQL query result resource + * @param int $index Field number, starting from 0 * @return string */ function fieldType( $res, $index ) { @@ -1405,7 +1451,7 @@ SQL; } /** - * @param $b + * @param string $b * @return Blob */ function encodeBlob( $b ) { @@ -1425,7 +1471,7 @@ SQL; } /** - * @param $s null|bool|Blob + * @param null|bool|Blob $s * @return int|string */ function addQuotes( $s ) { @@ -1444,10 +1490,7 @@ SQL; * Postgres specific version of replaceVars. * Calls the parent version in Database.php * - * @private - * * @param string $ins SQL string, read from a stream (usually tables.sql) - * * @return string SQL string */ protected function replaceVars( $ins ) { @@ -1468,10 +1511,8 @@ SQL; /** * Various select options * - * @private - * * @param array $options an associative array of options to be turned into - * an SQL query, valid keys are listed in the function. + * an SQL query, valid keys are listed in the function. * @return array */ function makeSelectOptions( $options ) { @@ -1549,9 +1590,9 @@ SQL; * Check to see if a named lock is available. This is non-blocking. * See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS * - * @param string $lockName name of lock to poll - * @param string $method name of method calling us - * @return Boolean + * @param string $lockName Name of lock to poll + * @param string $method Name of method calling us + * @return bool * @since 1.20 */ public function lockIsFree( $lockName, $method ) { @@ -1565,9 +1606,9 @@ SQL; /** * See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS - * @param $lockName string - * @param $method string - * @param $timeout int + * @param string $lockName + * @param string $method + * @param int $timeout * @return bool */ public function lock( $lockName, $method, $timeout = 5 ) { @@ -1590,8 +1631,8 @@ SQL; /** * See http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKSFROM * PG DOCS: http://www.postgresql.org/docs/8.2/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS - * @param $lockName string - * @param $method string + * @param string $lockName + * @param string $method * @return bool */ public function unlock( $lockName, $method ) { diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index ea35391d21..130d650426 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -119,8 +119,7 @@ class DatabaseSqlite extends DatabaseBase { /** * Opens a database file * - * @param $fileName string - * + * @param string $fileName * @throws DBConnectionError * @return PDO|bool SQL connection or false if failed */ @@ -136,10 +135,12 @@ class DatabaseSqlite extends DatabaseBase { } catch ( PDOException $e ) { $err = $e->getMessage(); } + if ( !$this->mConn ) { wfDebug( "DB connection error: $err\n" ); throw new DBConnectionError( $this, $err ); } + $this->mOpened = !!$this->mConn; # set error codes only, don't raise exceptions if ( $this->mOpened ) { @@ -165,7 +166,7 @@ class DatabaseSqlite extends DatabaseBase { * Generates a database file name. Explicitly public for installer. * @param string $dir Directory where database resides * @param string $dbName Database name - * @return String + * @return string */ public static function generateFileName( $dir, $dbName ) { return "$dir/$dbName.sqlite"; @@ -191,7 +192,7 @@ class DatabaseSqlite extends DatabaseBase { /** * Returns version of currently supported SQLite fulltext search module or false if none present. - * @return String + * @return string */ static function getFulltextSearchModule() { static $cachedResult = null; @@ -215,12 +216,11 @@ class DatabaseSqlite extends DatabaseBase { * Attaches external database to our connection, see http://sqlite.org/lang_attach.html * for details. * - * @param string $name database name to be used in queries like + * @param string $name Database name to be used in queries like * SELECT foo FROM dbname.table - * @param string $file database file name. If omitted, will be generated + * @param bool|string $file Database file name. If omitted, will be generated * using $name and $wgSQLiteDataDir - * @param string $fname calling function name - * + * @param string $fname Calling function name * @return ResultWrapper */ function attachDatabase( $name, $file = false, $fname = __METHOD__ ) { @@ -237,7 +237,6 @@ class DatabaseSqlite extends DatabaseBase { * @see DatabaseBase::isWriteQuery() * * @param $sql string - * * @return bool */ function isWriteQuery( $sql ) { @@ -247,9 +246,8 @@ class DatabaseSqlite extends DatabaseBase { /** * SQLite doesn't allow buffered results or data seeking etc, so we'll use fetchAll as the result * - * @param $sql string - * - * @return ResultWrapper + * @param string $sql + * @return bool|ResultWrapper */ protected function doQuery( $sql ) { $res = $this->mConn->query( $sql ); @@ -265,7 +263,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper + * @param ResultWrapper|mixed $res */ function freeResult( $res ) { if ( $res instanceof ResultWrapper ) { @@ -276,8 +274,8 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper - * @return object|bool + * @param ResultWrapper|array $res + * @return stdClass|bool */ function fetchObject( $res ) { if ( $res instanceof ResultWrapper ) { @@ -303,7 +301,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper + * @param ResultWrapper|mixed $res * @return array|bool */ function fetchRow( $res ) { @@ -325,8 +323,7 @@ class DatabaseSqlite extends DatabaseBase { /** * The PDO::Statement class implements the array interface so count() will work * - * @param $res ResultWrapper - * + * @param ResultWrapper|array $res * @return int */ function numRows( $res ) { @@ -336,7 +333,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper + * @param ResultWrapper $res * @return int */ function numFields( $res ) { @@ -346,7 +343,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper + * @param ResultWrapper $res * @param $n * @return bool */ @@ -364,8 +361,8 @@ class DatabaseSqlite extends DatabaseBase { /** * Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks * - * @param $name - * @param $format String + * @param string $name + * @param string $format * @return string */ function tableName( $name, $format = 'quoted' ) { @@ -380,8 +377,7 @@ class DatabaseSqlite extends DatabaseBase { /** * Index names have DB scope * - * @param $index string - * + * @param string $index * @return string */ function indexName( $index ) { @@ -399,8 +395,8 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $res ResultWrapper - * @param $row + * @param ResultWrapper|array $res + * @param int $row */ function dataSeek( $res, $row ) { if ( $res instanceof ResultWrapper ) { @@ -453,6 +449,9 @@ class DatabaseSqlite extends DatabaseBase { * Returns false if the index does not exist * - if errors are explicitly ignored, returns NULL on failure * + * @param string $table + * @param string $index + * @param string $fname * @return array */ function indexInfo( $table, $index, $fname = __METHOD__ ) { @@ -473,9 +472,9 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $table - * @param $index - * @param $fname string + * @param string $table + * @param string $index + * @param string $fname * @return bool|null */ function indexUnique( $table, $index, $fname = __METHOD__ ) { @@ -502,8 +501,7 @@ class DatabaseSqlite extends DatabaseBase { /** * Filter the options used in SELECT statements * - * @param $options array - * + * @param array $options * @return array */ function makeSelectOptions( $options ) { @@ -517,7 +515,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $options array + * @param array $options * @return string */ function makeUpdateOptions( $options ) { @@ -527,7 +525,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $options array + * @param array $options * @return array */ static function fixIgnore( $options ) { @@ -542,7 +540,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $options array + * @param array $options * @return string */ function makeInsertOptions( $options ) { @@ -553,6 +551,10 @@ class DatabaseSqlite extends DatabaseBase { /** * Based on generic method (parent) with some prior SQLite-sepcific adjustments + * @param string $table + * @param array $a + * @param string $fname + * @param array $options * @return bool */ function insert( $table, $a, $fname = __METHOD__, $options = array() ) { @@ -576,10 +578,10 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $table - * @param $uniqueIndexes - * @param $rows - * @param $fname string + * @param string $table + * @param array $uniqueIndexes Unused + * @param string|array $rows + * @param string $fname * @return bool|ResultWrapper */ function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) { @@ -606,6 +608,8 @@ class DatabaseSqlite extends DatabaseBase { * Returns the size of a text field, or -1 for "unlimited" * In SQLite this is SQLITE_MAX_LENGTH, by default 1GB. No way to query it though. * + * @param string $table + * @param string $field * @return int */ function textFieldSize( $table, $field ) { @@ -620,8 +624,8 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $sqls - * @param $all + * @param string $sqls + * @param bool $all Whether to "UNION ALL" or not * @return string */ function unionQueries( $sqls, $all ) { @@ -680,8 +684,8 @@ class DatabaseSqlite extends DatabaseBase { * Get information about a given field * Returns false if the field does not exist. * - * @param $table string - * @param $field string + * @param string $table + * @param string $field * @return SQLiteField|bool False on failure */ function fieldInfo( $table, $field ) { @@ -730,7 +734,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $s string + * @param string $s * @return string */ function strencode( $s ) { @@ -758,7 +762,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $s Blob|string + * @param Blob|string $s * @return string */ function addQuotes( $s ) { @@ -800,6 +804,7 @@ class DatabaseSqlite extends DatabaseBase { /** * No-op version of deadlockLoop + * * @return mixed */ public function deadlockLoop( /*...*/ ) { @@ -810,7 +815,7 @@ class DatabaseSqlite extends DatabaseBase { } /** - * @param $s string + * @param string $s * @return string */ protected function replaceVars( $s ) { @@ -866,8 +871,7 @@ class DatabaseSqlite extends DatabaseBase { /** * Build a concatenation list to feed into a SQL query * - * @param $stringList array - * + * @param string[] $stringList * @return string */ function buildConcat( $stringList ) { @@ -884,10 +888,10 @@ class DatabaseSqlite extends DatabaseBase { /** * @throws MWException - * @param $oldName - * @param $newName - * @param $temporary bool - * @param $fname string + * @param string $oldName + * @param string $newName + * @param bool $temporary + * @param string $fname * @return bool|ResultWrapper */ function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) { @@ -919,7 +923,7 @@ class DatabaseSqlite extends DatabaseBase { * List all tables on the database * * @param string $prefix Only show tables with this prefix, e.g. mw_ - * @param string $fname calling function name + * @param string $fname Calling function name * * @return array */ diff --git a/includes/db/DatabaseUtility.php b/includes/db/DatabaseUtility.php index 5451e987f2..7d36a38df5 100644 --- a/includes/db/DatabaseUtility.php +++ b/includes/db/DatabaseUtility.php @@ -129,7 +129,7 @@ class ResultWrapper implements Iterator { /** * Get the number of rows in a result object * - * @return integer + * @return int */ function numRows() { return $this->db->numRows( $this ); @@ -151,7 +151,7 @@ class ResultWrapper implements Iterator { * Fetch the next row from the given result object, in associative array * form. Fields are retrieved with $row['fieldname']. * - * @return Array + * @return array * @throws DBUnexpectedError Thrown if the database returns an error */ function fetchRow() { @@ -171,7 +171,7 @@ class ResultWrapper implements Iterator { * Change the position of the cursor in a result object. * See mysql_data_seek() * - * @param $row integer + * @param int $row */ function seek( $row ) { $this->db->dataSeek( $this, $row ); @@ -302,6 +302,7 @@ class FakeResultWrapper extends ResultWrapper { * manually, use DatabaseBase::anyChar() and anyString() instead. */ class LikeMatch { + /** @var string */ private $str; /** @@ -316,7 +317,7 @@ class LikeMatch { /** * Return the original stored string. * - * @return String + * @return string */ public function toString() { return $this->str; diff --git a/includes/db/LBFactory.php b/includes/db/LBFactory.php index 847e173ccc..ae105e2660 100644 --- a/includes/db/LBFactory.php +++ b/includes/db/LBFactory.php @@ -59,7 +59,6 @@ abstract class LBFactory { * Returns the LBFactory class to use and the load balancer configuration. * * @param array $config (e.g. $wgLBFactoryConf) - * * @return string class name */ public static function getLBFactoryClass( array $config ) { @@ -99,7 +98,7 @@ abstract class LBFactory { /** * Set the instance to be the given object * - * @param $instance LBFactory + * @param LBFactory $instance */ static function setInstance( $instance ) { self::destroyInstance(); @@ -108,7 +107,7 @@ abstract class LBFactory { /** * Construct a factory based on a configuration array (typically from $wgLBFactoryConf) - * @param $conf + * @param array $conf */ abstract function __construct( $conf ); @@ -116,7 +115,7 @@ abstract class LBFactory { * Create a new load balancer object. The resulting object will be untracked, * not chronology-protected, and the caller is responsible for cleaning it up. * - * @param string $wiki wiki ID, or false for the current wiki + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancer */ abstract function newMainLB( $wiki = false ); @@ -124,7 +123,7 @@ abstract class LBFactory { /** * Get a cached (tracked) load balancer object. * - * @param string $wiki wiki ID, or false for the current wiki + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancer */ abstract function getMainLB( $wiki = false ); @@ -134,9 +133,8 @@ abstract class LBFactory { * untracked, not chronology-protected, and the caller is responsible for * cleaning it up. * - * @param string $cluster external storage cluster, or false for core - * @param string $wiki wiki ID, or false for the current wiki - * + * @param string $cluster External storage cluster, or false for core + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancer */ abstract function newExternalLB( $cluster, $wiki = false ); @@ -145,8 +143,7 @@ abstract class LBFactory { * Get a cached (tracked) load balancer for external storage * * @param string $cluster external storage cluster, or false for core - * @param string $wiki wiki ID, or false for the current wiki - * + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancer */ abstract function &getExternalLB( $cluster, $wiki = false ); @@ -155,7 +152,8 @@ abstract class LBFactory { * Execute a function for each tracked load balancer * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. - * @param $callback string|array + * + * @param callable $callback * @param array $params */ abstract function forEachLB( $callback, $params = array() ); @@ -169,8 +167,9 @@ abstract class LBFactory { /** * Call a method of each tracked load balancer - * @param $methodName string - * @param $args array + * + * @param string $methodName + * @param array $args */ function forEachLBCallMethod( $methodName, $args = array() ) { $this->forEachLB( array( $this, 'callMethod' ), array( $methodName, $args ) ); @@ -178,8 +177,8 @@ abstract class LBFactory { /** * Private helper for forEachLBCallMethod - * @param $loadBalancer - * @param $methodName string + * @param LoadBalancer $loadBalancer + * @param string $methodName * @param $args */ function callMethod( $loadBalancer, $methodName, $args ) { @@ -212,7 +211,7 @@ class LBFactorySimple extends LBFactory { } /** - * @param $wiki + * @param bool|string $wiki * @return LoadBalancer */ function newMainLB( $wiki = false ) { @@ -249,7 +248,7 @@ class LBFactorySimple extends LBFactory { } /** - * @param $wiki + * @param bool|string $wiki * @return LoadBalancer */ function getMainLB( $wiki = false ) { @@ -264,8 +263,8 @@ class LBFactorySimple extends LBFactory { /** * @throws MWException - * @param $cluster - * @param $wiki + * @param string $cluster + * @param bool|string $wiki * @return LoadBalancer */ function newExternalLB( $cluster, $wiki = false ) { @@ -280,8 +279,8 @@ class LBFactorySimple extends LBFactory { } /** - * @param $cluster - * @param $wiki + * @param string $cluster + * @param bool|string $wiki * @return array */ function &getExternalLB( $cluster, $wiki = false ) { @@ -298,8 +297,9 @@ class LBFactorySimple extends LBFactory { * Execute a function for each tracked load balancer * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. - * @param $callback - * @param $params array + * + * @param callable $callback + * @param array $params */ function forEachLB( $callback, $params = array() ) { if ( isset( $this->mainLB ) ) { diff --git a/includes/db/LBFactoryMulti.php b/includes/db/LBFactoryMulti.php index 2ab0554811..3c1885f1bc 100644 --- a/includes/db/LBFactoryMulti.php +++ b/includes/db/LBFactoryMulti.php @@ -149,7 +149,7 @@ class LBFactoryMulti extends LBFactory { protected $lastSection; /** - * @param $conf array + * @param array $conf * @throws MWException */ function __construct( $conf ) { @@ -183,7 +183,7 @@ class LBFactoryMulti extends LBFactory { } /** - * @param $wiki bool|string + * @param bool|string $wiki * @return string */ function getSectionForWiki( $wiki = false ) { @@ -203,7 +203,7 @@ class LBFactoryMulti extends LBFactory { } /** - * @param $wiki bool|string + * @param bool|string $wiki * @return LoadBalancer */ function newMainLB( $wiki = false ) { @@ -226,7 +226,7 @@ class LBFactoryMulti extends LBFactory { } /** - * @param $wiki bool|string + * @param bool|string $wiki * @return LoadBalancer */ function getMainLB( $wiki = false ) { @@ -243,7 +243,7 @@ class LBFactoryMulti extends LBFactory { /** * @param string $cluster - * @param bool $wiki + * @param bool|string $wiki * @throws MWException * @return LoadBalancer */ @@ -263,8 +263,8 @@ class LBFactoryMulti extends LBFactory { } /** - * @param $cluster - * @param $wiki + * @param string $cluster external storage cluster, or false for core + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancer */ function &getExternalLB( $cluster, $wiki = false ) { @@ -280,9 +280,9 @@ class LBFactoryMulti extends LBFactory { /** * Make a new load balancer object based on template and load array * - * @param $template - * @param $loads array - * @param $groupLoads + * @param array $template + * @param array $loads + * @param array $groupLoads * @return LoadBalancer */ function newLoadBalancer( $template, $loads, $groupLoads ) { @@ -299,9 +299,9 @@ class LBFactoryMulti extends LBFactory { /** * Make a server array as expected by LoadBalancer::__construct, using a template and load array * - * @param $template - * @param $loads array - * @param $groupLoads + * @param array $template + * @param array $loads + * @param array $groupLoads * @return array */ function makeServerArray( $template, $loads, $groupLoads ) { @@ -343,7 +343,7 @@ class LBFactoryMulti extends LBFactory { /** * Take a group load array indexed by group then server, and reindex it by server then group - * @param $groupLoads + * @param array $groupLoads * @return array */ function reindexGroupLoads( $groupLoads ) { @@ -359,7 +359,7 @@ class LBFactoryMulti extends LBFactory { /** * Get the database name and prefix based on the wiki ID - * @param $wiki bool + * @param bool|string $wiki * @return array */ function getDBNameAndPrefix( $wiki = false ) { @@ -376,8 +376,8 @@ class LBFactoryMulti extends LBFactory { * Execute a function for each tracked load balancer * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. - * @param $callback - * @param $params array + * @param callable $callback + * @param array $params */ function forEachLB( $callback, $params = array() ) { foreach ( $this->mainLBs as $lb ) { diff --git a/includes/db/LBFactorySingle.php b/includes/db/LBFactorySingle.php index 83271ecb29..66e9d12758 100644 --- a/includes/db/LBFactorySingle.php +++ b/includes/db/LBFactorySingle.php @@ -25,6 +25,7 @@ * An LBFactory class that always returns a single database object. */ class LBFactorySingle extends LBFactory { + /** @var LoadBalancerSingle */ protected $lb; /** @@ -36,8 +37,7 @@ class LBFactorySingle extends LBFactory { } /** - * @param $wiki bool|string - * + * @param bool|string $wiki * @return LoadBalancerSingle */ function newMainLB( $wiki = false ) { @@ -45,8 +45,7 @@ class LBFactorySingle extends LBFactory { } /** - * @param $wiki bool|string - * + * @param bool|string $wiki * @return LoadBalancerSingle */ function getMainLB( $wiki = false ) { @@ -54,9 +53,8 @@ class LBFactorySingle extends LBFactory { } /** - * @param $cluster - * @param $wiki bool|string - * + * @param string $cluster External storage cluster, or false for core + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancerSingle */ function newExternalLB( $cluster, $wiki = false ) { @@ -64,9 +62,8 @@ class LBFactorySingle extends LBFactory { } /** - * @param $cluster - * @param $wiki bool|string - * + * @param string $cluster external storage cluster, or false for core + * @param bool|string $wiki Wiki ID, or false for the current wiki * @return LoadBalancerSingle */ function &getExternalLB( $cluster, $wiki = false ) { @@ -74,8 +71,8 @@ class LBFactorySingle extends LBFactory { } /** - * @param $callback string|array - * @param $params array + * @param string|array $callback + * @param array $params */ function forEachLB( $callback, $params = array() ) { call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) ); @@ -104,8 +101,8 @@ class LoadBalancerSingle extends LoadBalancer { /** * - * @param $server string - * @param $dbNameOverride bool + * @param string $server + * @param bool $dbNameOverride * * @return DatabaseBase */ diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 7dcb88f15e..7a49c78ece 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -31,16 +31,20 @@ class LoadBalancer { private $mServers, $mConns, $mLoads, $mGroupLoads; private $mErrorConnection; private $mReadIndex, $mAllowLagged; - private $mWaitForPos, $mWaitTimeout; + + /** @var bool|DBMasterPos False if not set */ + private $mWaitForPos; + + private $mWaitTimeout; private $mLaggedSlaveMode, $mLastError = 'Unknown error'; private $mParentInfo, $mLagTimes; private $mLoadMonitorClass, $mLoadMonitor; /** * @param array $params with keys: - * servers Required. Array of server info structures. - * masterWaitTimeout Replication lag wait timeout - * loadMonitor Name of a class used to fetch server lag and load. + * servers Required. Array of server info structures. + * masterWaitTimeout Replication lag wait timeout + * loadMonitor Name of a class used to fetch server lag and load. * @throws MWException */ function __construct( $params ) { @@ -108,7 +112,7 @@ class LoadBalancer { /** * Get or set arbitrary data used by the parent object, usually an LBFactory * @param $x - * @return Mixed + * @return mixed */ function parentInfo( $x = null ) { return wfSetVar( $this->mParentInfo, $x ); @@ -120,8 +124,7 @@ class LoadBalancer { * * @deprecated since 1.21, use ArrayUtils::pickRandom() * - * @param $weights array - * + * @param array $weights * @return bool|int|string */ function pickRandom( $weights ) { @@ -129,8 +132,8 @@ class LoadBalancer { } /** - * @param $loads array - * @param $wiki bool + * @param array $loads + * @param bool|string $wiki Wiki to get non-lagged for * @return bool|int|string */ function getRandomNonLagged( $loads, $wiki = false ) { @@ -177,8 +180,8 @@ class LoadBalancer { * always return a consistent index during a given invocation * * Side effect: opens connections to databases - * @param $group bool - * @param $wiki bool + * @param bool|string $group + * @param bool|string $wiki * @throws MWException * @return bool|int|string */ @@ -338,7 +341,7 @@ class LoadBalancer { /** * Wait for a specified number of microseconds, and return the period waited - * @param $t int + * @param int $t * @return int */ function sleep( $t ) { @@ -354,7 +357,7 @@ class LoadBalancer { * Set the master wait position * If a DB_SLAVE connection has been opened already, waits * Otherwise sets a variable telling it to wait if such a connection is opened - * @param $pos DBMasterPos + * @param DBMasterPos $pos */ public function waitFor( $pos ) { wfProfileIn( __METHOD__ ); @@ -372,7 +375,7 @@ class LoadBalancer { /** * Set the master wait position and wait for ALL slaves to catch up to it - * @param $pos DBMasterPos + * @param DBMasterPos $pos */ public function waitForAll( $pos ) { wfProfileIn( __METHOD__ ); @@ -390,7 +393,7 @@ class LoadBalancer { * Get any open connection to a given server index, local or foreign * Returns false if there is no connection open * - * @param $i int + * @param int $i * @return DatabaseBase|bool False on failure */ function getAnyOpenConnection( $i ) { @@ -575,7 +578,7 @@ class LoadBalancer { * * @param integer $db * @param mixed $groups - * @param string $wiki + * @param bool|string $wiki * @return DBConnRef */ public function getConnectionRef( $db, $groups = array(), $wiki = false ) { @@ -591,7 +594,7 @@ class LoadBalancer { * * @param integer $db * @param mixed $groups - * @param string $wiki + * @param bool|string $wiki * @return DBConnRef */ public function getLazyConnectionRef( $db, $groups = array(), $wiki = false ) { @@ -607,7 +610,7 @@ class LoadBalancer { * error will be available via $this->mErrorConnection. * * @param $i Integer server index - * @param string $wiki wiki ID to open + * @param bool|string $wiki wiki ID to open * @return DatabaseBase * * @access private @@ -998,7 +1001,7 @@ class LoadBalancer { /** * Disables/enables lag checks - * @param $mode null + * @param null|bool $mode * @return bool */ function allowLagged( $mode = null ) { @@ -1030,7 +1033,7 @@ class LoadBalancer { /** * Call a function with each open connection object - * @param $callback + * @param callable $callback * @param array $params */ function forEachOpenConnection( $callback, $params = array() ) { @@ -1050,8 +1053,7 @@ class LoadBalancer { * May attempt to open connections to slaves on the default DB. If there is * no lag, the maximum lag will be reported as -1. * - * @param string $wiki Wiki ID, or false for the default database - * + * @param bool|string $wiki Wiki ID, or false for the default database * @return array ( host, max lag, index of max lagged host ) */ function getMaxLag( $wiki = false ) { @@ -1086,8 +1088,7 @@ class LoadBalancer { * Get lag time for each server * Results are cached for a short time in memcached, and indefinitely in the process cache * - * @param $wiki - * + * @param string|bool $wiki * @return array */ function getLagTimes( $wiki = false ) { @@ -1118,8 +1119,7 @@ class LoadBalancer { * function instead of Database::getLag() avoids a fatal error in this * case on many installations. * - * @param $conn DatabaseBase - * + * @param DatabaseBase $conn * @return int */ function safeGetLag( $conn ) { @@ -1148,14 +1148,16 @@ class LoadBalancer { class DBConnRef implements IDatabase { /** @var LoadBalancer */ protected $lb; + /** @var DatabaseBase|null */ protected $conn; - /** @var Array|null */ + + /** @var array|null */ protected $params; /** - * @param $lb LoadBalancer - * @param $conn DatabaseBase|array Connection or (server index, group, wiki ID) array + * @param LoadBalancer $lb + * @param DatabaseBase|array $conn Connection or (server index, group, wiki ID) array */ public function __construct( LoadBalancer $lb, $conn ) { $this->lb = $lb; diff --git a/includes/db/LoadMonitor.php b/includes/db/LoadMonitor.php index 58544565f3..651c499f4b 100644 --- a/includes/db/LoadMonitor.php +++ b/includes/db/LoadMonitor.php @@ -37,7 +37,7 @@ interface LoadMonitor { /** * Perform pre-connection load ratio adjustment. * @param array $loads - * @param string|bool $group the selected query group. Default: false + * @param string|bool $group The selected query group. Default: false * @param string|bool $wiki Default: false */ function scaleLoads( &$loads, $group = false, $wiki = false ); @@ -55,16 +55,16 @@ interface LoadMonitor { * to the running thread count. The threshold may be false, which indicates * that the sysadmin has not configured this feature. * - * @param $conn DatabaseBase - * @param $threshold Float + * @param DatabaseBase $conn + * @param float $threshold */ function postConnectionBackoff( $conn, $threshold ); /** * Return an estimate of replication lag for each server * - * @param $serverIndexes - * @param $wiki + * @param array $serverIndexes + * @param string $wiki * * @return array */ @@ -82,8 +82,8 @@ class LoadMonitorNull implements LoadMonitor { } /** - * @param $serverIndexes - * @param $wiki + * @param array $serverIndexes + * @param string $wiki * @return array */ function getLagTimes( $serverIndexes, $wiki ) { @@ -98,9 +98,7 @@ class LoadMonitorNull implements LoadMonitor { * @ingroup Database */ class LoadMonitorMySQL implements LoadMonitor { - /** - * @var LoadBalancer - */ + /** @var LoadBalancer */ public $parent; /** @@ -111,16 +109,16 @@ class LoadMonitorMySQL implements LoadMonitor { } /** - * @param $loads - * @param $group bool - * @param $wiki bool + * @param array $loads + * @param bool $group + * @param bool $wiki */ function scaleLoads( &$loads, $group = false, $wiki = false ) { } /** - * @param $serverIndexes - * @param $wiki + * @param array $serverIndexes + * @param string $wiki * @return array */ function getLagTimes( $serverIndexes, $wiki ) { @@ -192,8 +190,8 @@ class LoadMonitorMySQL implements LoadMonitor { } /** - * @param $conn DatabaseBase - * @param $threshold + * @param DatabaseBase|DatabaseMySQLBase $conn + * @param int $threshold * @return int */ function postConnectionBackoff( $conn, $threshold ) { diff --git a/includes/db/ORMTable.php b/includes/db/ORMTable.php index e47bc672de..3f91e0a33b 100644 --- a/includes/db/ORMTable.php +++ b/includes/db/ORMTable.php @@ -246,9 +246,9 @@ class ORMTable extends DBAccessBase implements IORMTable { * @param array $conditions * @param array $options * @param null|string $functionName - * * @return ResultWrapper - * @throws DBQueryError if the quey failed (even if the database was in ignoreErrors mode). + * @throws DBQueryError if the query failed (even if the database was in + * ignoreErrors mode). */ public function rawSelect( $fields = null, array $conditions = array(), array $options = array(), $functionName = null @@ -378,7 +378,7 @@ class ORMTable extends DBAccessBase implements IORMTable { * @param array $options * @param string|null $functionName * - * @return ResultWrapper + * @return stdClass */ public function rawSelectRow( array $fields, array $conditions = array(), array $options = array(), $functionName = null @@ -825,7 +825,7 @@ class ORMTable extends DBAccessBase implements IORMTable { * @since 1.20 * * @param stdClass $result - * + * @throws MWException * @return array */ public function getFieldsFromDBResult( stdClass $result ) { -- 2.20.1