* 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.
* 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 ) {
* 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 ) {
*/
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
/**
* Change the table prefix on all open DB connections/
*
- * @param $prefix
+ * @param string $prefix
* @return void
*/
public static function changePrefix( $prefix ) {
}
/**
- * @param $lb LoadBalancer
- * @param $prefix
+ * @param LoadBalancer $lb
+ * @param string $prefix
* @return void
*/
public static function changeLBPrefix( $lb, $prefix ) {
}
/**
- * @param $db DatabaseBase
- * @param $prefix
+ * @param DatabaseBase $db
+ * @param string $prefix
* @return void
*/
public static function changeDBPrefix( $db, $prefix ) {
* 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 );
* 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
*/
/**
* 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 );
* 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 );
* 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 );
* 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 );
* 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
*/
* @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__ );
/**
* 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 );
* 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();
* 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();
* 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();
}
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;
protected $mServer, $mUser, $mPassword, $mDBname;
+ /** @var resource Database connection */
protected $mConn = null;
protected $mOpened = false;
* 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;
/**
* Record if possible write queries were done in the last transaction started
*
- * @var Bool
+ * @var bool
* @see DatabaseBase::mTrxLevel
*/
private $mTrxDoneWrites = false;
/**
* Record if the current transaction was started implicitly due to DBO_TRX being set.
*
- * @var Bool
+ * @var bool
* @see DatabaseBase::mTrxLevel
*/
private $mTrxAutomatic = false;
/**
* 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;
* 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;
/**
* 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
* 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 ) {
*
* 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 ) {
/**
* Set the filehandle to copy write statements to.
*
- * @param $fh filehandle
+ * @param resource $fh File handle
*/
public function setFileHandle( $fh ) {
$this->fileHandle = $fh;
* 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 ) {
/**
* Set lag time in seconds for a fake slave
*
- * @param $lag int
+ * @param int $lag
*/
public function setFakeSlaveLag( $lag ) {
$this->mFakeSlaveLag = $lag;
/**
* Make this connection a fake master
*
- * @param $enabled bool
+ * @param bool $enabled
*/
public function setFakeMaster( $enabled = true ) {
$this->mFakeMaster = $enabled;
/**
* Return the last query that went through DatabaseBase::query()
- * @return String
+ * @return string
*/
public function lastQuery() {
return $this->mLastQuery;
/**
* Is a connection to the database open?
- * @return Boolean
+ * @return bool
*/
public function isOpen() {
return $this->mOpened;
/**
* 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
/**
* 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;
/**
* 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 );
/**
* General read-only accessor
*
- * @param $name string
- *
+ * @param string $name
* @return string
*/
public function getProperty( $name ) {
* 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;
* @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(
/**
* @param $errno
- * @param $errstr
- * @access private
+ * @param string $errstr
*/
public function connectionErrorHandler( $errno, $errstr ) {
$this->mPHPError = $errstr;
* 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
/**
* 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' ) {
/**
* 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 );
* 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 ) {
*
* 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 ) {
}
$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.
* 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 ) {
* & = 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
*/
/**
* Free a prepared query, generated by prepare().
- * @param $prepared
+ * @param string $prepared
*/
protected function freePrepared( $prepared ) {
/* No-op by default */
/**
* 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
*/
/**
* 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 );
* 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] ) {
* 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 ) {
}
* 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 ) {
/**
* 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
/**
* 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
* @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:
* 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
* 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
* - 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
* - 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
*
* 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.
* @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()
* @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
*/
*
* 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()
/**
* 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 );
* 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__ ) {
/**
* 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__ ) {
/**
* Determines if a given index is unique
*
- * @param $table string
- * @param $index string
+ * @param string $table
+ * @param string $index
*
* @return bool
*/
/**
* Helper for DatabaseBase::insert().
*
- * @param $options array
+ * @param array $options
* @return string
*/
protected function makeInsertOptions( $options ) {
* 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
/**
* 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 );
/**
* 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
*/
* 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 ) {
* Return aggregated value alias
*
* @param $valuedata
- * @param $valuename string
+ * @param string $valuename
*
* @return string
*/
}
/**
- * @param $field
+ * @param string $field
* @return string
*/
public function bitNot( $field ) {
}
/**
- * @param $fieldLeft
- * @param $fieldRight
+ * @param string $fieldLeft
+ * @param string $fieldRight
* @return string
*/
public function bitAnd( $fieldLeft, $fieldRight ) {
}
/**
- * @param $fieldLeft
- * @param $fieldRight
+ * @param string $fieldLeft
+ * @param string $fieldRight
* @return string
*/
public function bitOr( $fieldLeft, $fieldRight ) {
/**
* 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 ) . ')';
* @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(
* 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;
/**
* 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();
/**
* 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();
* 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(
/**
* Get the name of an index in a given table
*
- * @param $index
- *
+ * @param string $index
* @return string
*/
protected function indexName( $index ) {
/**
* Adds quotes and backslashes.
*
- * @param $s string
- *
+ * @param string $s
* @return string
*/
public function addQuotes( $s ) {
* 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 ) {
* 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 ) {
* $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();
* 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;
* 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 ) {
* 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__ ) {
* 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
* 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__
*
* 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,
/**
* 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 ) {
* 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
*/
* @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()
* 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
*/
* 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 (';
* @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 ) ) {
* 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
*/
/**
* 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.
*/
/**
* 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 ) ) {
/**
* 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 ) {
* 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__ ) {
* 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 );
*
* 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() ) {
* Issues the COMMIT command to the database server.
*
* @see DatabaseBase::commit()
- * @param type $fname
+ * @param string $fname
*/
protected function doCommit( $fname ) {
if ( $this->mTrxLevel ) {
*
* No-op on non-transactional databases.
*
- * @param $fname string
+ * @param string $fname
*/
final public function rollback( $fname = __METHOD__ ) {
if ( !$this->mTrxLevel ) {
* Issues the ROLLBACK command to the database server.
*
* @see DatabaseBase::rollback()
- * @param type $fname
+ * @param string $fname
*/
protected function doRollback( $fname ) {
if ( $this->mTrxLevel ) {
* 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__
* 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__ ) {
/**
* 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
*/
* 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
*/
* 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
*/
* 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 ) {
* 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 ) {
* 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 ) {
* 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 ) {
* @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
*/
* 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;
* 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;
* 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,
*
* @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 ) {
* 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();
/**
* Replace variables in sourced SQL
*
- * @param $ins string
- *
+ * @param string $ins
* @return string
*/
protected function replaceVars( $ins ) {
/**
* Table name callback
*
- * @param $matches array
- *
+ * @param array $matches
* @return string
*/
protected function tableNameCallback( $matches ) {
/**
* Index name callback
*
- * @param $matches array
- *
+ * @param array $matches
* @return string
*/
protected function indexNameCallback( $matches ) {
/**
* 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 ) {
* 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;
/**
* 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 ) {
/**
* Unlock specific tables
*
- * @param string $method the caller
- *
+ * @param string $method The caller
* @return bool
*/
public function unlockTables( $method ) {
/**
* Delete a table
- * @param $tableName string
- * @param $fName string
+ * @param string $tableName
+ * @param string $fName
* @return bool|ResultWrapper
* @since 1.18
*/
* 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';
* 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';
* 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() )
* 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() )
*
* 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 ) {
* @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 ) {
* @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';
}
/**
- * @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;
}
/**
- * @return string
+ * @return string Safe HTML
*/
function getHTML() {
global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors;
}
}
+ /**
+ * Output the exception report using HTML.
+ *
+ * @return void
+ */
public function reportHTML() {
global $wgUseFileCache;
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 " .
}
/**
- * @return boolean
+ * @return bool
*/
function isLoggable() {
// Don't send to the exception log, already in dberror log
* 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() {
/**
* @param string $key Message key
- * @return string: English message text
+ * @return string English message text
*/
private function getFallbackMessage( $key ) {
$messages = array(
return sqlsrv_close( $this->mConn );
}
+ /**
+ * @param string $sql
+ * @return bool|MssqlResult
+ * @throws DBUnexpectedError
+ */
protected function doQuery( $sql ) {
wfDebug( "SQL: [$sql]\n" );
$this->offset = 0;
return $res;
}
+ /**
+ * @param mixed|ResultWrapper $res
+ */
function freeResult( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
$res->free();
}
+ /**
+ * @param ResultWrapper|stdClass $res
+ * @return stdClass
+ */
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $row;
}
+ /**
+ * @return string
+ */
function getErrors() {
$strRet = '';
$retErrors = sqlsrv_errors( SQLSRV_ERR_ALL );
return $strRet;
}
+ /**
+ * @param resource $res
+ * @return Blob
+ */
function fetchRow( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $row;
}
+ /**
+ * @param mixed $res
+ * @return int
+ */
function numRows( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $this->mInsertId;
}
+ /**
+ * @param mixed $res
+ * @param int $row
+ * @return bool
+ */
function dataSeek( $res, $row ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
/**
* 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__,
/**
* 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()
* 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 = '',
/**
* 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__ ) {
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;
/**
* 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 ) ) {
/**
* 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" );
}
}
- # 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
/**
* 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 ) {
}
}
- // 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';
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]";
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'" );
/**
* 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__ ) {
* 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
*/
}
/**
- * @private
+ * @param array $tables
+ * @param array $use_index
+ * @param array $join_conds
* @return string
*/
function tableNamesWithUseIndexOrJOIN( $tables, $use_index = array(), $join_conds = array() ) {
}
/**
- * @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 = '';
* @ingroup Database
*/
class MssqlResult {
-
+ /**
+ * @param bool|resource $queryresult
+ */
public function __construct( $queryresult = false ) {
$this->mCursor = 0;
$this->mRows = array();
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 ) ) {
*/
class DatabaseMysql extends DatabaseMysqlBase {
/**
- * @param $sql string
- * @return resource
+ * @param string $sql
+ * @return resource False on error
*/
protected function doQuery( $sql ) {
if ( $this->bufferResults() ) {
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
}
/**
+ * @param string $charset
* @return bool
*/
protected function mysqlSetCharset( $charset ) {
}
/**
- * @param $db
+ * @param string $db
* @return bool
*/
function selectDB( $db ) {
}
/**
- * @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;
/**
* Open a connection to a MySQL server
*
- * @param $realServer string
+ * @param string $realServer
* @return mixed Raw connection
* @throws DBConnectionError
*/
abstract protected function mysqlSetCharset( $charset );
/**
- * @param $res ResultWrapper
+ * @param ResultWrapper|resource $res
* @throws DBUnexpectedError
*/
function freeResult( $res ) {
/**
* 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 ) {
/**
* 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
*/
/**
* 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 ) {
/**
* 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 ) {
/**
* 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
*/
/**
* Get the name of the specified field in a result
*
- * @param $res Raw result
+ * @param ResultWrapper|resource $res
* @param $n int
* @return string
*/
/**
* mysql_field_type() wrapper
- * @param $res
+ * @param ResultWrapper|resource $res
* @param $n int
* @return string
*/
/**
* 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 ) {
/**
* 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 );
/**
* 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__ ) {
* 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()
}
/**
- * @param $table string
- * @param $field string
+ * @param string $table
+ * @param string $field
* @return bool|MySQLField
*/
function fieldInfo( $table, $field ) {
/**
* 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 );
* 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__ ) {
}
/**
- * @param $s string
- *
+ * @param string $s
* @return string
*/
function strencode( $s ) {
/**
* 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 ) {
}
/**
- * @param $name string
+ * @param string $name
* @return bool
*/
public function isQuotedIdentifier( $name ) {
/**
* 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 ) {
}
/**
- * @param $index
+ * @param string $index
* @return string
*/
function useIndexClause( $index ) {
}
/**
- * @param $options array
+ * @param array $options
*/
public function setSessionOptions( array $options ) {
if ( isset( $options['connTimeout'] ) ) {
}
}
+ /**
+ * @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 );
*
* @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 ) {
}
/**
- * @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 ) {
/**
* 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 ) {
}
/**
- * @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 ) {
}
/**
- * @param $method string
+ * @param string $method
* @return bool
*/
public function unlockTables( $method ) {
* 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';
/**
* @param bool $value
- * @return mixed
+ * @return mixed null|bool|ResultWrapper
*/
public function setBigSelects( $value = true ) {
if ( $value === 'default' ) {
}
/**
- * @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 ' : '';
* 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__ ) {
/**
* Get status information from SHOW STATUS in an associative array
*
- * @param $which string
+ * @param string $which
* @return array
*/
function getMysqlStatus( $which = "%" ) {
/**
* 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
*/
}
class MySQLMasterPos implements DBMasterPos {
- var $file, $pos;
+ /** @var string */
+ public $file;
+
+ /** @var int */
+ private $pos;
function __construct( $file, $pos ) {
$this->file = $file;
*/
class DatabaseMysqli extends DatabaseMysqlBase {
/**
- * @param $sql string
+ * @param string $sql
* @return resource
*/
protected function doQuery( $sql ) {
return $ret;
}
+ /**
+ * @param string $realServer
+ * @return bool|mysqli
+ * @throws DBConnectionError
+ */
protected function mysqlConnect( $realServer ) {
global $wgDBmysql5;
# Fail now
}
/**
+ * @param string $charset
* @return bool
*/
protected function mysqlSetCharset( $charset ) {
}
/**
- * @param $db
+ * @param string $db
* @return bool
*/
function selectDB( $db ) {
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 ) {
return $object;
}
+ /**
+ * @param mysqli $res
+ * @return bool
+ */
protected function mysqlFetchArray( $res ) {
$array = $res->fetch_array();
if ( $array === null ) {
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;
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();
}
}
+ /**
+ * 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 );
}
}
/**
- * @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 ) {
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;
$res->free();
}
+ /**
+ * @param ResultWrapper|stdClass $res
+ * @return mixed
+ */
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $this->mInsertId;
}
+ /**
+ * @param mixed $res
+ * @param int $row
+ */
function dataSeek( $res, $row ) {
if ( $res instanceof ORAResult ) {
$res->seek( $row );
/**
* 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__ ) {
return $bind;
}
+ /**
+ * @param string $table
+ * @param $row
+ * @param string $fname
+ * @return bool
+ * @throws DBUnexpectedError
+ */
private function insertOneRow( $table, $row, $fname ) {
global $wgContLang;
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'] );
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 );
/**
* Return aggregated value function call
+ *
+ * @param $valuedata
+ * @param string $valuename
+ * @return mixed
*/
public function aggregateValue( $valuedata, $valuename = 'value' ) {
return $valuedata;
/**
* Query whether a given index exists
+ * @param string $table
+ * @param string $index
+ * @param string $fname
* @return bool
*/
function indexExists( $table, $index, $fname = __METHOD__ ) {
/**
* 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__ ) {
* 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 ) {
/**
* @throws DBUnexpectedError
- * @param $table
- * @param $field
+ * @param string $table
+ * @param string $field
* @return ORAField
*/
function fieldInfo( $table, $field ) {
}
}
- /* 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 = '';
* 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 ) {
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;
public function getInfinity() {
return '31-12-2030 12:00:00.000000';
}
-} // end DatabaseOracle class
+}
$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 ) {
* @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;
* @param string $user
* @param string $password
* @param string $dbName
- * @throws DBConnectionError
+ * @throws DBConnectionError|Exception
* @return DatabaseBase|null
*/
function open( $server, $user, $password, $dbName ) {
/**
* 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 ) {
return $this->query( $sql, $fname, true );
}
+ /**
+ * @param stdClass|ResultWrapper $res
+ * @throws DBUnexpectedError
+ */
function freeResult( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
}
+ /**
+ * @param ResultWrapper|stdClass $res
+ * @return stdClass
+ * @throws DBUnexpectedError
+ */
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $this->mInsertId;
}
+ /**
+ * @param mixed $res
+ * @param int $row
+ * @return bool
+ */
function dataSeek( $res, $row ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
* 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 = '',
/**
* 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__ ) {
* 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 ) {
* $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() ) {
* $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__,
* 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 );
* 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 ) {
}
/**
- * @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]';
* 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__ );
* 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__ );
/**
* 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 ) {
/**
* 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 ) {
/**
* Query whether a given schema exists. Returns true if it does, false if it doesn't.
+ * @param string $schema
* @return bool
*/
function schemaExists( $schema ) {
/**
* Returns true if a given role (i.e. user) exists, false otherwise.
+ * @param string $roleName
* @return bool
*/
function roleExists( $roleName ) {
/**
* 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 ) {
}
/**
- * @param $b
+ * @param string $b
* @return Blob
*/
function encodeBlob( $b ) {
}
/**
- * @param $s null|bool|Blob
+ * @param null|bool|Blob $s
* @return int|string
*/
function addQuotes( $s ) {
* 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 ) {
/**
* 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 ) {
* 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 ) {
/**
* 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 ) {
/**
* 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 ) {
/**
* Opens a database file
*
- * @param $fileName string
- *
+ * @param string $fileName
* @throws DBConnectionError
* @return PDO|bool SQL connection or false if failed
*/
} 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 ) {
* 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";
/**
* Returns version of currently supported SQLite fulltext search module or false if none present.
- * @return String
+ * @return string
*/
static function getFulltextSearchModule() {
static $cachedResult = null;
* 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__ ) {
* @see DatabaseBase::isWriteQuery()
*
* @param $sql string
- *
* @return bool
*/
function isWriteQuery( $sql ) {
/**
* 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 );
}
/**
- * @param $res ResultWrapper
+ * @param ResultWrapper|mixed $res
*/
function freeResult( $res ) {
if ( $res instanceof ResultWrapper ) {
}
/**
- * @param $res ResultWrapper
- * @return object|bool
+ * @param ResultWrapper|array $res
+ * @return stdClass|bool
*/
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
}
/**
- * @param $res ResultWrapper
+ * @param ResultWrapper|mixed $res
* @return array|bool
*/
function fetchRow( $res ) {
/**
* The PDO::Statement class implements the array interface so count() will work
*
- * @param $res ResultWrapper
- *
+ * @param ResultWrapper|array $res
* @return int
*/
function numRows( $res ) {
}
/**
- * @param $res ResultWrapper
+ * @param ResultWrapper $res
* @return int
*/
function numFields( $res ) {
}
/**
- * @param $res ResultWrapper
+ * @param ResultWrapper $res
* @param $n
* @return bool
*/
/**
* 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' ) {
/**
* Index names have DB scope
*
- * @param $index string
- *
+ * @param string $index
* @return string
*/
function indexName( $index ) {
}
/**
- * @param $res ResultWrapper
- * @param $row
+ * @param ResultWrapper|array $res
+ * @param int $row
*/
function dataSeek( $res, $row ) {
if ( $res instanceof ResultWrapper ) {
* 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__ ) {
}
/**
- * @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__ ) {
/**
* Filter the options used in SELECT statements
*
- * @param $options array
- *
+ * @param array $options
* @return array
*/
function makeSelectOptions( $options ) {
}
/**
- * @param $options array
+ * @param array $options
* @return string
*/
function makeUpdateOptions( $options ) {
}
/**
- * @param $options array
+ * @param array $options
* @return array
*/
static function fixIgnore( $options ) {
}
/**
- * @param $options array
+ * @param array $options
* @return string
*/
function makeInsertOptions( $options ) {
/**
* 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() ) {
}
/**
- * @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__ ) {
* 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 ) {
}
/**
- * @param $sqls
- * @param $all
+ * @param string $sqls
+ * @param bool $all Whether to "UNION ALL" or not
* @return string
*/
function unionQueries( $sqls, $all ) {
* 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 ) {
}
/**
- * @param $s string
+ * @param string $s
* @return string
*/
function strencode( $s ) {
}
/**
- * @param $s Blob|string
+ * @param Blob|string $s
* @return string
*/
function addQuotes( $s ) {
/**
* No-op version of deadlockLoop
+ *
* @return mixed
*/
public function deadlockLoop( /*...*/ ) {
}
/**
- * @param $s string
+ * @param string $s
* @return string
*/
protected function replaceVars( $s ) {
/**
* Build a concatenation list to feed into a SQL query
*
- * @param $stringList array
- *
+ * @param string[] $stringList
* @return string
*/
function buildConcat( $stringList ) {
/**
* @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__ ) {
* 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
*/
/**
* Get the number of rows in a result object
*
- * @return integer
+ * @return int
*/
function numRows() {
return $this->db->numRows( $this );
* 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() {
* 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 );
* manually, use DatabaseBase::anyChar() and anyString() instead.
*/
class LikeMatch {
+ /** @var string */
private $str;
/**
/**
* Return the original stored string.
*
- * @return String
+ * @return string
*/
public function toString() {
return $this->str;
* 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 ) {
/**
* Set the instance to be the given object
*
- * @param $instance LBFactory
+ * @param LBFactory $instance
*/
static function setInstance( $instance ) {
self::destroyInstance();
/**
* Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
- * @param $conf
+ * @param array $conf
*/
abstract function __construct( $conf );
* 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 );
/**
* 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 );
* 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 );
* 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 );
* 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() );
/**
* 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 ) );
/**
* Private helper for forEachLBCallMethod
- * @param $loadBalancer
- * @param $methodName string
+ * @param LoadBalancer $loadBalancer
+ * @param string $methodName
* @param $args
*/
function callMethod( $loadBalancer, $methodName, $args ) {
}
/**
- * @param $wiki
+ * @param bool|string $wiki
* @return LoadBalancer
*/
function newMainLB( $wiki = false ) {
}
/**
- * @param $wiki
+ * @param bool|string $wiki
* @return LoadBalancer
*/
function getMainLB( $wiki = false ) {
/**
* @throws MWException
- * @param $cluster
- * @param $wiki
+ * @param string $cluster
+ * @param bool|string $wiki
* @return LoadBalancer
*/
function newExternalLB( $cluster, $wiki = false ) {
}
/**
- * @param $cluster
- * @param $wiki
+ * @param string $cluster
+ * @param bool|string $wiki
* @return array
*/
function &getExternalLB( $cluster, $wiki = false ) {
* 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 ) ) {
protected $lastSection;
/**
- * @param $conf array
+ * @param array $conf
* @throws MWException
*/
function __construct( $conf ) {
}
/**
- * @param $wiki bool|string
+ * @param bool|string $wiki
* @return string
*/
function getSectionForWiki( $wiki = false ) {
}
/**
- * @param $wiki bool|string
+ * @param bool|string $wiki
* @return LoadBalancer
*/
function newMainLB( $wiki = false ) {
}
/**
- * @param $wiki bool|string
+ * @param bool|string $wiki
* @return LoadBalancer
*/
function getMainLB( $wiki = false ) {
/**
* @param string $cluster
- * @param bool $wiki
+ * @param bool|string $wiki
* @throws MWException
* @return LoadBalancer
*/
}
/**
- * @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 ) {
/**
* 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 ) {
/**
* 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 ) {
/**
* 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 ) {
/**
* Get the database name and prefix based on the wiki ID
- * @param $wiki bool
+ * @param bool|string $wiki
* @return array
*/
function getDBNameAndPrefix( $wiki = false ) {
* 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 ) {
* An LBFactory class that always returns a single database object.
*/
class LBFactorySingle extends LBFactory {
+ /** @var LoadBalancerSingle */
protected $lb;
/**
}
/**
- * @param $wiki bool|string
- *
+ * @param bool|string $wiki
* @return LoadBalancerSingle
*/
function newMainLB( $wiki = false ) {
}
/**
- * @param $wiki bool|string
- *
+ * @param bool|string $wiki
* @return LoadBalancerSingle
*/
function getMainLB( $wiki = false ) {
}
/**
- * @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 ) {
}
/**
- * @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 ) {
}
/**
- * @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 ) );
/**
*
- * @param $server string
- * @param $dbNameOverride bool
+ * @param string $server
+ * @param bool $dbNameOverride
*
* @return DatabaseBase
*/
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 ) {
/**
* 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 );
*
* @deprecated since 1.21, use ArrayUtils::pickRandom()
*
- * @param $weights array
- *
+ * @param array $weights
* @return bool|int|string
*/
function pickRandom( $weights ) {
}
/**
- * @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 ) {
* 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
*/
/**
* Wait for a specified number of microseconds, and return the period waited
- * @param $t int
+ * @param int $t
* @return int
*/
function sleep( $t ) {
* 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__ );
/**
* 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__ );
* 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 ) {
*
* @param integer $db
* @param mixed $groups
- * @param string $wiki
+ * @param bool|string $wiki
* @return DBConnRef
*/
public function getConnectionRef( $db, $groups = array(), $wiki = false ) {
*
* @param integer $db
* @param mixed $groups
- * @param string $wiki
+ * @param bool|string $wiki
* @return DBConnRef
*/
public function getLazyConnectionRef( $db, $groups = array(), $wiki = false ) {
* 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
/**
* Disables/enables lag checks
- * @param $mode null
+ * @param null|bool $mode
* @return bool
*/
function allowLagged( $mode = null ) {
/**
* Call a function with each open connection object
- * @param $callback
+ * @param callable $callback
* @param array $params
*/
function forEachOpenConnection( $callback, $params = array() ) {
* 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 ) {
* 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 ) {
* 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 ) {
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;
/**
* 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 );
* 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
*/
}
/**
- * @param $serverIndexes
- * @param $wiki
+ * @param array $serverIndexes
+ * @param string $wiki
* @return array
*/
function getLagTimes( $serverIndexes, $wiki ) {
* @ingroup Database
*/
class LoadMonitorMySQL implements LoadMonitor {
- /**
- * @var LoadBalancer
- */
+ /** @var LoadBalancer */
public $parent;
/**
}
/**
- * @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 ) {
}
/**
- * @param $conn DatabaseBase
- * @param $threshold
+ * @param DatabaseBase|DatabaseMySQLBase $conn
+ * @param int $threshold
* @return int
*/
function postConnectionBackoff( $conn, $threshold ) {
* @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
* @param array $options
* @param string|null $functionName
*
- * @return ResultWrapper
+ * @return stdClass
*/
public function rawSelectRow( array $fields, array $conditions = array(),
array $options = array(), $functionName = null
* @since 1.20
*
* @param stdClass $result
- *
+ * @throws MWException
* @return array
*/
public function getFieldsFromDBResult( stdClass $result ) {