Fix all line length related CodeSniffer warnings.
Change-Id: Id0fd8f4c7276185f51489659ee3cd06962fbc16d
self::changePrefix( $this->newTablePrefix );
$newTableName = $this->db->tableName( $tbl, 'raw' );
- if ( $this->dropCurrentTables && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) ) ) {
+ if ( $this->dropCurrentTables
+ && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) )
+ ) {
$this->db->dropTable( $tbl, __METHOD__ );
wfDebug( __METHOD__ . " dropping {$newTableName}\n", true );
//Dropping the oldTable because the prefix was changed
* not restored on unserialize.
*/
public function __sleep() {
- throw new MWException( 'Database serialization may cause problems, since the connection is not restored on wakeup.' );
+ throw new MWException( 'Database serialization may cause problems, since ' .
+ 'the connection is not restored on wakeup.' );
}
/**
return $arg;
case '&':
# return $this->addQuotes( file_get_contents( $arg ) );
- throw new DBUnexpectedError( $this, '& mode is not implemented. If it\'s really needed, uncomment the line above.' );
+ throw new DBUnexpectedError(
+ $this,
+ '& mode is not implemented. If it\'s really needed, uncomment the line above.'
+ );
default:
- throw new DBUnexpectedError( $this, 'Received invalid match. This should never happen!' );
+ throw new DBUnexpectedError(
+ $this,
+ 'Received invalid match. This should never happen!'
+ );
}
}
list( $table ) = $dbDetails;
if ( $wgSharedDB !== null # We have a shared database
&& $this->mForeign == false # We're not working on a foreign database
- && !$this->isQuotedIdentifier( $table ) # Paranoia check to prevent shared tables listing '`table`'
+ && !$this->isQuotedIdentifier( $table ) # Prevent shared tables listing '`table`'
&& in_array( $table, $wgSharedTables ) # A shared table is selected
) {
$database = $wgSharedDB;
}
/**
- * LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match
- * containing either string literals that will be escaped or tokens returned by anyChar() or anyString().
- * Alternatively, the function could be provided with an array of aforementioned parameters.
+ * LIKE statement wrapper, receives a variable-length argument list with
+ * parts of pattern to match containing either string literals that will be
+ * escaped or tokens returned by anyChar() or anyString(). Alternatively,
+ * the function could be provided with an array of aforementioned
+ * parameters.
*
- * Example: $dbr->buildLike( 'My_page_title/', $dbr->anyString() ) returns a LIKE clause that searches
- * for subpages of 'My page title'.
- * Alternatively: $pattern = array( 'My_page_title/', $dbr->anyString() ); $query .= $dbr->buildLike( $pattern );
+ * Example: $dbr->buildLike( 'My_page_title/', $dbr->anyString() ) returns
+ * a LIKE clause that searches for subpages of 'My page title'.
+ * Alternatively:
+ * $pattern = array( 'My_page_title/', $dbr->anyString() );
+ * $query .= $dbr->buildLike( $pattern );
*
* @since 1.16
* @return String: fully built LIKE statement
}
/**
- * Begin a transaction. If a transaction is already in progress, that transaction will be committed before the
- * new transaction is started.
+ * Begin a transaction. If a transaction is already in progress,
+ * that transaction will be committed before the new transaction is started.
*
- * Note that when the DBO_TRX flag is set (which is usually the case for web requests, but not for maintenance scripts),
- * any previous database query will have started a transaction automatically.
+ * Note that when the DBO_TRX flag is set (which is usually the case for web
+ * requests, but not for maintenance scripts), any previous database query
+ * will have started a transaction automatically.
*
- * Nesting of transactions is not supported. Attempts to nest transactions will cause a warning, unless the current
- * transaction was started automatically because of the DBO_TRX flag.
+ * Nesting of transactions is not supported. Attempts to nest transactions
+ * will cause a warning, unless the current transaction was started
+ * automatically because of the DBO_TRX flag.
*
* @param $fname string
* @throws DBError
* Nesting of transactions is not supported.
*
* @param $fname string
- * @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.
+ * @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.
*/
final public function commit( $fname = __METHOD__, $flush = '' ) {
if ( !$this->mTrxAtomicLevels->isEmpty() ) {
// There are still atomic sections open. This cannot be ignored
- throw new DBUnexpectedError( $this, "Attempted to commit transaction while atomic sections are still open" );
+ throw new DBUnexpectedError(
+ $this,
+ "Attempted to commit transaction while atomic sections are still open"
+ );
}
if ( $flush != 'flush' ) {
* @param bool|callable $lineCallback Optional function called before reading each line
* @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
+ * generated dynamically using $filename
+ * @param bool|callable $inputCallback Callback: Optional function called
+ * for each complete line sent
* @throws MWException
* @throws Exception|MWException
* @return bool|string
function getHTML() {
global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors;
- $sorry = htmlspecialchars( $this->msg( 'dberr-problems', 'Sorry! This site is experiencing technical difficulties.' ) );
- $again = htmlspecialchars( $this->msg( 'dberr-again', 'Try waiting a few minutes and reloading.' ) );
+ $sorry = htmlspecialchars( $this->msg(
+ 'dberr-problems',
+ 'Sorry! This site is experiencing technical difficulties.'
+ ) );
+ $again = htmlspecialchars( $this->msg(
+ 'dberr-again',
+ 'Try waiting a few minutes and reloading.'
+ ) );
if ( $wgShowHostnames || $wgShowSQLErrors ) {
$info = str_replace(
htmlspecialchars( $this->msg( 'dberr-info', '(Cannot contact the database server: $1)' ) )
);
} else {
- $info = htmlspecialchars( $this->msg( 'dberr-info-hidden', '(Cannot contact the database server)' ) );
+ $info = htmlspecialchars( $this->msg(
+ 'dberr-info-hidden',
+ '(Cannot contact the database server)'
+ ) );
}
# No database access
function searchForm() {
global $wgSitename, $wgCanonicalServer, $wgRequest;
- $usegoogle = htmlspecialchars( $this->msg( 'dberr-usegoogle', 'You can try searching via Google in the meantime.' ) );
- $outofdate = htmlspecialchars( $this->msg( 'dberr-outofdate', 'Note that their indexes of our content may be out of date.' ) );
+ $usegoogle = htmlspecialchars( $this->msg(
+ 'dberr-usegoogle',
+ 'You can try searching via Google in the meantime.'
+ ) );
+ $outofdate = htmlspecialchars( $this->msg(
+ 'dberr-outofdate',
+ 'Note that their indexes of our content may be out of date.'
+ ) );
$googlesearch = htmlspecialchars( $this->msg( 'searchbutton', 'Search' ) );
$search = htmlspecialchars( $wgRequest->getVal( 'search' ) );
* @param $fname string
*/
function __construct( DatabaseBase $db, $error, $errno, $sql, $fname ) {
- $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
+ $message = "A database error has occurred. Did you forget to run " .
+ "maintenance/update.php after upgrading? See: " .
+ "https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
"Query: $sql\n" .
"Function: $fname\n" .
"Error: $errno $error\n";
function open( $server, $user, $password, $dbName ) {
# Test for driver support, to avoid suppressed fatal error
if ( !function_exists( 'sqlsrv_connect' ) ) {
- throw new DBConnectionError( $this, "MS Sql Server Native (sqlsrv) functions missing. You can download the driver from: http://go.microsoft.com/fwlink/?LinkId=123470\n" );
+ throw new DBConnectionError(
+ $this,
+ "MS Sql Server Native (sqlsrv) functions missing. You can download " .
+ "the driver from: http://go.microsoft.com/fwlink/?LinkId=123470\n" );
}
global $wgDBport;
- if ( !strlen( $user ) ) { # e.g. the class is being loaded
+ # e.g. the class is being loaded
+ if ( !strlen( $user ) ) {
return;
}
// Start NT Auth Hack
// Quick and dirty work around to provide NT Auth designation support.
- // Current solution requires installer to know to input 'ntauth' for both username and password
- // to trigger connection via NT Auth. - ugly, ugly, ugly
- // TO-DO: Make this better and add NT Auth choice to MW installer when SQL Server option is chosen.
+ // Current solution requires installer to know to input 'ntauth' for
+ // both username and password to trigger connection via NT Auth. Ugly,
+ // ugly, ugly!
+ // @todo Make this better and add NT Auth choice to MW installer when
+ // SQL Server option is chosen.
$ntAuthUserTest = strtolower( $user );
$ntAuthPassTest = strtolower( $password );
if ( $this->mConn === false ) {
wfDebug( "DB connection error\n" );
- wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
+ wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " .
+ substr( $password, 0, 3 ) . "...\n" );
wfDebug( $this->lastError() . "\n" );
return false;
wfDebug( "SQL: [$sql]\n" );
$this->offset = 0;
- // several extensions seem to think that all databases support limits via LIMIT N after the WHERE clause
- // well, MSSQL uses SELECT TOP N, so to catch any of those extensions we'll do a quick check for a LIMIT
- // clause and pass $sql through $this->LimitToTopN() which parses the limit clause and passes the result to
- // $this->limitResult();
+ // several extensions seem to think that all databases support limits
+ // via LIMIT N after the WHERE clause well, MSSQL uses SELECT TOP N,
+ // so to catch any of those extensions we'll do a quick check for a
+ // LIMIT clause and pass $sql through $this->LimitToTopN() which parses
+ // the limit clause and passes the result to $this->limitResult();
if ( preg_match( '/\bLIMIT\s*/i', $sql ) ) {
// massage LIMIT -> TopN
$sql = $this->LimitToTopN( $sql );
// perform query
$stmt = sqlsrv_query( $this->mConn, $sql );
if ( $stmt == false ) {
- $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
+ $message = "A database error has occurred. Did you forget " .
+ "to run maintenance/update.php after upgrading? See: " .
+ "http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
"Query: " . htmlentities( $sql ) . "\n" .
"Function: " . __METHOD__ . "\n";
// process each error (our driver will give us an array of errors unlike other providers)
// remember number of rows affected
$this->mAffectedRows = sqlsrv_rows_affected( $stmt );
- // if it is a SELECT statement, or an insert with a request to output something we want to return a row.
+ // if it is a SELECT statement, or an insert with a request to output
+ // something we want to return a row.
if ( ( preg_match( '#\bSELECT\s#i', $sql ) ) ||
( preg_match( '#\bINSERT\s#i', $sql ) && preg_match( '#\bOUTPUT\s+INSERTED\b#i', $sql ) )
) {
* @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. 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 Mixed: database result resource (feed to Database::fetchObject or whatever), or false on failure
+ * @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 Mixed: database result resource (feed to Database::fetchObject
+ * or whatever), or false on failure
*/
- function select( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) {
+ function select( $table, $vars, $conds = '', $fname = __METHOD__,
+ $options = array(), $join_conds = array()
+ ) {
$sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds );
if ( isset( $options['EXPLAIN'] ) ) {
sqlsrv_query( $this->mConn, "SET SHOWPLAN_ALL ON;" );
* (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() ) {
+ function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__,
+ $options = array(), $join_conds = array()
+ ) {
if ( isset( $options['EXPLAIN'] ) ) {
unset( $options['EXPLAIN'] );
}
* Takes same arguments as Database::select()
* @return int
*/
- function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() ) {
+ function estimateRowCount( $table, $vars = '*', $conds = '',
+ $fname = __METHOD__, $options = array()
+ ) {
// http://msdn2.microsoft.com/en-us/library/aa259203.aspx
$options['EXPLAIN'] = true;
$res = $this->select( $table, $vars, $conds, $fname, $options );
* @return array|bool|null
*/
function indexInfo( $table, $index, $fname = __METHOD__ ) {
- # This does not return the same info as MYSQL would, but that's OK because MediaWiki never uses the
- # returned value except to check for the existance of indexes.
+ # This does not return the same info as MYSQL would, but that's OK
+ # because MediaWiki never uses the returned value except to check for
+ # the existance of indexes.
$sql = "sp_helpindex '" . $table . "'";
$res = $this->query( $sql, $fname );
if ( !$res ) {
// We know the table we're inserting into, get its identity column
$identity = null;
- $tableRaw = preg_replace( '#\[([^\]]*)\]#', '$1', $table ); // strip matching square brackets from table name
- $res = $this->doQuery( "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'" );
+ // strip matching square brackets from table name
+ $tableRaw = preg_replace( '#\[([^\]]*)\]#', '$1', $table );
+ $res = $this->doQuery(
+ "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS " .
+ "WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'"
+ );
if ( $res && $res->numrows() ) {
// There is an identity for this table.
$identity = array_pop( $res->fetch( SQLSRV_FETCH_ASSOC ) );
unset( $res );
foreach ( $arrToInsert as $a ) {
- // start out with empty identity column, this is so we can return it as a result of the insert logic
+ // start out with empty identity column, this is so we can return
+ // it as a result of the insert logic
$sqlPre = '';
$sqlPost = '';
$identityClause = '';
}
}
}
- $identityClause = "OUTPUT INSERTED.$identity "; // we want to output an identity column as result
+
+ // we want to output an identity column as result
+ $identityClause = "OUTPUT INSERTED.$identity ";
}
$keys = array_keys( $a );
// translate MySQL INSERT IGNORE to something SQL Server can use
// example:
// MySQL: INSERT IGNORE INTO user_groups (ug_user,ug_group) VALUES ('1','sysop')
- // MSSQL: IF NOT EXISTS (SELECT * FROM user_groups WHERE ug_user = '1') INSERT INTO user_groups (ug_user,ug_group) VALUES ('1','sysop')
+ // MSSQL: IF NOT EXISTS (SELECT * FROM user_groups WHERE ug_user = '1')
+ // INSERT INTO user_groups (ug_user,ug_group) VALUES ('1','sysop')
if ( $ignoreClause ) {
$prival = $a[$keys[0]];
$sqlPre .= "IF NOT EXISTS (SELECT * FROM $table WHERE $keys[0] = '$prival')";
/**
* INSERT SELECT wrapper
* $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 Database::addQuotes()
- * $conds may be "*" to copy the whole table
- * srcTable may be an array of tables.
+ * Source items may be literals rather than field names, but strings should
+ * be quoted with Database::addQuotes().
* @param string $destTable
- * @param array|string $srcTable
+ * @param array|string $srcTable May be an array of tables.
* @param array $varMap
- * @param array $conds
+ * @param array $conds May be "*" to copy the whole table.
* @param string $fname
* @param array $insertOptions
* @param array $selectOptions
*/
function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__,
$insertOptions = array(), $selectOptions = array() ) {
- $ret = parent::insertSelect( $destTable, $srcTable, $varMap, $conds, $fname, $insertOptions, $selectOptions );
+ $ret = parent::insertSelect(
+ $destTable,
+ $srcTable,
+ $varMap,
+ $conds,
+ $fname,
+ $insertOptions,
+ $selectOptions
+ );
if ( $ret === false ) {
throw new DBQueryError( $this, $this->getErrors(), $this->lastErrno(), /*$sql*/ '', $fname );
*/
function nextSequenceValue( $seqName ) {
if ( !$this->tableExists( 'sequence_' . $seqName ) ) {
- sqlsrv_query( $this->mConn, "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)" );
+ sqlsrv_query(
+ $this->mConn,
+ "CREATE TABLE [sequence_$seqName] (id INT NOT NULL IDENTITY PRIMARY KEY, junk varchar(10) NULL)"
+ );
}
sqlsrv_query( $this->mConn, "INSERT INTO [sequence_$seqName] (junk) VALUES ('')" );
$ret = sqlsrv_query( $this->mConn, "SELECT TOP 1 id FROM [sequence_$seqName] ORDER BY id DESC" );
- $row = sqlsrv_fetch_array( $ret, SQLSRV_FETCH_ASSOC ); // KEEP ASSOC THERE, weird weird bug dealing with the return value if you don't
+ // KEEP ASSOC THERE, weird weird bug dealing with the return value if you don't
+ $row = sqlsrv_fetch_array( $ret, SQLSRV_FETCH_ASSOC );
sqlsrv_free_stmt( $ret );
$this->mInsertId = $row['id'];
}
}
- // 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.
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';
throw new MWException( "The identifier '$identifier' is too long (max. 128)" );
}
if ( ( strpos( $identifier, '[' ) !== false ) || ( strpos( $identifier, ']' ) !== false ) ) {
- // It may be allowed if you quoted with double quotation marks, but that would break if QUOTED_IDENTIFIER is OFF
+ // It may be allowed if you quoted with double quotation marks, but
+ // that would break if QUOTED_IDENTIFIER is OFF
throw new MWException( "You can't use square brackers in the identifier '$identifier'" );
}
}
/**
- * The MSSQL PHP driver doesn't support sqlsrv_num_rows, so we recall all rows into an array and maintain our
- * own cursor index into that array...This is similar to the way the Oracle driver handles this same issue
+ * The MSSQL PHP driver doesn't support sqlsrv_num_rows, so we recall all rows
+ * into an array and maintain our own cursor index into that array... This is
+ * similar to the way the Oracle driver handles this same issue
*
* @ingroup Database
*/
# Fail now
# Otherwise we get a suppressed fatal error, which is very hard to track down
if ( !extension_loaded( 'mysql' ) ) {
- throw new DBConnectionError( $this, "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" );
+ throw new DBConnectionError(
+ $this,
+ "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n"
+ );
}
$connFlags = 0;
// these are the only errors mysql_fetch_object can cause.
// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
if ( $errno == 2000 || $errno == 2013 ) {
- throw new DBUnexpectedError( $this, 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() ) );
+ throw new DBUnexpectedError(
+ $this,
+ 'Error in fetchObject(): ' . htmlspecialchars( $this->lastError() )
+ );
}
return $row;
// these are the only errors mysql_fetch_array can cause.
// See http://dev.mysql.com/doc/refman/5.0/en/mysql-fetch-row.html.
if ( $errno == 2000 || $errno == 2013 ) {
- throw new DBUnexpectedError( $this, 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() ) );
+ throw new DBUnexpectedError(
+ $this,
+ 'Error in fetchRow(): ' . htmlspecialchars( $this->lastError() )
+ );
}
return $row;
* @param $options string|array
* @return int
*/
- public function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() ) {
+ public function estimateRowCount( $table, $vars = '*', $conds = '',
+ $fname = __METHOD__, $options = array()
+ ) {
$options['EXPLAIN'] = true;
$res = $this->select( $table, $vars, $conds, $fname, $options );
if ( $res === false ) {
$row = $this->fetchObject( $res );
if ( $row ) {
- $pos = isset( $row->Exec_master_log_pos ) ? $row->Exec_master_log_pos : $row->Exec_Master_Log_Pos;
+ $pos = isset( $row->Exec_master_log_pos )
+ ? $row->Exec_master_log_pos
+ : $row->Exec_Master_Log_Pos;
return new MySQLMasterPos( $row->Relay_Master_Log_File, $pos );
} else {
}
/**
- * FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
+ * FROM MYSQL DOCS:
+ * http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
* @param $lockName string
* @param $method string
* @return bool
protected function getDefaultSchemaVars() {
$vars = parent::getDefaultSchemaVars();
$vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $GLOBALS['wgDBTableOptions'] );
- $vars['wgDBTableOptions'] = str_replace( 'CHARSET=mysql4', 'CHARSET=binary', $vars['wgDBTableOptions'] );
+ $vars['wgDBTableOptions'] = str_replace(
+ 'CHARSET=mysql4',
+ 'CHARSET=binary',
+ $vars['wgDBTableOptions']
+ );
return $vars;
}
function __construct( &$db, $stmt, $unique = false ) {
$this->db =& $db;
- if ( ( $this->nrows = oci_fetch_all( $stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM ) ) === false ) {
+ $this->nrows = oci_fetch_all( $stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM );
+ if ( $this->nrows === false ) {
$e = oci_error( $stmt );
$db->reportQueryError( $e['message'], $e['code'], '', __METHOD__ );
$this->free();
function open( $server, $user, $password, $dbName ) {
global $wgDBOracleDRCP;
if ( !function_exists( 'oci_connect' ) ) {
- throw new DBConnectionError( $this, "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n (Note: if you recently installed PHP, you may need to restart your webserver and database)\n" );
+ throw new DBConnectionError(
+ $this,
+ "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n " .
+ "(Note: if you recently installed PHP, you may need to restart your webserver\n " .
+ "and database)\n" );
}
$this->close();
wfSuppressWarnings();
if ( $this->mFlags & DBO_PERSISTENT ) {
- $this->mConn = oci_pconnect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
+ $this->mConn = oci_pconnect(
+ $this->mUser,
+ $this->mPassword,
+ $this->mServer,
+ $this->defaultCharset,
+ $session_mode
+ );
} elseif ( $this->mFlags & DBO_DEFAULT ) {
- $this->mConn = oci_new_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
+ $this->mConn = oci_new_connect(
+ $this->mUser,
+ $this->mPassword,
+ $this->mServer,
+ $this->defaultCharset,
+ $session_mode
+ );
} else {
- $this->mConn = oci_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode );
+ $this->mConn = oci_connect(
+ $this->mUser,
+ $this->mPassword,
+ $this->mServer,
+ $this->defaultCharset,
+ $session_mode
+ );
}
wfRestoreWarnings();
// you have to select data from plan table after explain
$explain_id = MWTimestamp::getLocalInstance()->format( 'dmYHis' );
- $sql = preg_replace( '/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR', $sql, 1, $explain_count );
+ $sql = preg_replace(
+ '/^EXPLAIN /',
+ 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR',
+ $sql,
+ 1,
+ $explain_count
+ );
wfSuppressWarnings();
wfRestoreWarnings();
if ( $explain_count > 0 ) {
- return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table WHERE statement_id = \'' . $explain_id . '\'' );
+ return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table ' .
+ 'WHERE statement_id = \'' . $explain_id . '\'' );
} elseif ( oci_statement_type( $stmt ) == 'SELECT' ) {
return new ORAResult( $this, $stmt, $union_unique );
} else {
private function getSequenceData( $table ) {
if ( $this->sequenceData == null ) {
$result = $this->doQuery( "SELECT lower(asq.sequence_name),
- lower(atc.table_name),
- lower(atc.column_name)
- FROM all_sequences asq, all_tab_columns atc
- WHERE decode(atc.table_name, '{$this->mTablePrefix}MWUSER', '{$this->mTablePrefix}USER', atc.table_name) || '_' ||
- atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
- AND asq.sequence_owner = upper('{$this->mDBname}')
- AND atc.owner = upper('{$this->mDBname}')" );
+ lower(atc.table_name),
+ lower(atc.column_name)
+ FROM all_sequences asq, all_tab_columns atc
+ WHERE decode(
+ atc.table_name,
+ '{$this->mTablePrefix}MWUSER',
+ '{$this->mTablePrefix}USER',
+ atc.table_name
+ ) || '_' ||
+ atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
+ AND asq.sequence_owner = upper('{$this->mDBname}')
+ AND atc.owner = upper('{$this->mDBname}')" );
while ( ( $row = $result->fetchRow() ) !== false ) {
$this->sequenceData[$row[1]] = array(
function unionQueries( $sqls, $all ) {
$glue = ' UNION ALL ';
- return 'SELECT * ' . ( $all ? '' : '/* UNION_UNIQUE */ ' ) . 'FROM (' . implode( $glue, $sqls ) . ')';
+ return 'SELECT * ' . ( $all ? '' : '/* UNION_UNIQUE */ ' ) .
+ 'FROM (' . implode( $glue, $sqls ) . ')';
}
function wasDeadlock() {
return $this->lastErrno() == 'OCI-00060';
}
- function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) {
+ function duplicateTableStructure( $oldName, $newName, $temporary = false,
+ $fname = __METHOD__
+ ) {
$temporary = $temporary ? 'TRUE' : 'FALSE';
$newName = strtoupper( $newName );
$oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) );
$newPrefix = strtoupper( $this->mTablePrefix );
- return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', '$oldPrefix', '$newPrefix', $temporary ); END;" );
+ return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', " .
+ "'$oldPrefix', '$newPrefix', $temporary ); END;" );
}
function listTables( $prefix = null, $fname = __METHOD__ ) {
}
$owner = strtoupper( $this->mDBname );
- $result = $this->doQuery( "SELECT table_name FROM all_tables WHERE owner='$owner' AND table_name NOT LIKE '%!_IDX\$_' ESCAPE '!' $listWhere" );
+ $result = $this->doQuery( "SELECT table_name FROM all_tables " .
+ "WHERE owner='$owner' AND table_name NOT LIKE '%!_IDX\$_' ESCAPE '!' $listWhere" );
// dirty code ... i know
$endArray = array();
*/
function getServerVersion() {
//better version number, fallback on driver
- $rset = $this->doQuery( 'SELECT version FROM product_component_version WHERE UPPER(product) LIKE \'ORACLE DATABASE%\'' );
+ $rset = $this->doQuery(
+ 'SELECT version FROM product_component_version ' .
+ 'WHERE UPPER(product) LIKE \'ORACLE DATABASE%\''
+ );
if ( !( $row = $rset->fetchRow() ) ) {
return oci_server_version( $this->mConn );
}
$tableWhere = '= \'' . $table . '\'';
}
- $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name ' . $tableWhere . ' and column_name = \'' . $field . '\'' );
+ $fieldInfoStmt = oci_parse(
+ $this->mConn,
+ 'SELECT * FROM wiki_field_info_full WHERE table_name ' .
+ $tableWhere . ' and column_name = \'' . $field . '\''
+ );
if ( oci_execute( $fieldInfoStmt, $this->execFlags() ) === false ) {
$e = oci_error( $fieldInfoStmt );
$this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ );
return $conds2;
}
- function selectRow( $table, $vars, $conds, $fname = __METHOD__, $options = array(), $join_conds = array() ) {
+ function selectRow( $table, $vars, $conds, $fname = __METHOD__,
+ $options = array(), $join_conds = array()
+ ) {
if ( is_array( $conds ) ) {
$conds = $this->wrapConditionsForWhere( $table, $conds );
}
// all deletions on these tables have transactions so final failure rollbacks these updates
$table = $this->tableName( $table );
if ( $table == $this->tableName( 'user' ) ) {
- $this->update( 'archive', array( 'ar_user' => 0 ), array( 'ar_user' => $conds['user_id'] ), $fname );
- $this->update( 'ipblocks', array( 'ipb_user' => 0 ), array( 'ipb_user' => $conds['user_id'] ), $fname );
- $this->update( 'image', array( 'img_user' => 0 ), array( 'img_user' => $conds['user_id'] ), $fname );
- $this->update( 'oldimage', array( 'oi_user' => 0 ), array( 'oi_user' => $conds['user_id'] ), $fname );
- $this->update( 'filearchive', array( 'fa_deleted_user' => 0 ), array( 'fa_deleted_user' => $conds['user_id'] ), $fname );
- $this->update( 'filearchive', array( 'fa_user' => 0 ), array( 'fa_user' => $conds['user_id'] ), $fname );
- $this->update( 'uploadstash', array( 'us_user' => 0 ), array( 'us_user' => $conds['user_id'] ), $fname );
- $this->update( 'recentchanges', array( 'rc_user' => 0 ), array( 'rc_user' => $conds['user_id'] ), $fname );
- $this->update( 'logging', array( 'log_user' => 0 ), array( 'log_user' => $conds['user_id'] ), $fname );
+ $this->update( 'archive', array( 'ar_user' => 0 ),
+ array( 'ar_user' => $conds['user_id'] ), $fname );
+ $this->update( 'ipblocks', array( 'ipb_user' => 0 ),
+ array( 'ipb_user' => $conds['user_id'] ), $fname );
+ $this->update( 'image', array( 'img_user' => 0 ),
+ array( 'img_user' => $conds['user_id'] ), $fname );
+ $this->update( 'oldimage', array( 'oi_user' => 0 ),
+ array( 'oi_user' => $conds['user_id'] ), $fname );
+ $this->update( 'filearchive', array( 'fa_deleted_user' => 0 ),
+ array( 'fa_deleted_user' => $conds['user_id'] ), $fname );
+ $this->update( 'filearchive', array( 'fa_user' => 0 ),
+ array( 'fa_user' => $conds['user_id'] ), $fname );
+ $this->update( 'uploadstash', array( 'us_user' => 0 ),
+ array( 'us_user' => $conds['user_id'] ), $fname );
+ $this->update( 'recentchanges', array( 'rc_user' => 0 ),
+ array( 'rc_user' => $conds['user_id'] ), $fname );
+ $this->update( 'logging', array( 'log_user' => 0 ),
+ array( 'log_user' => $conds['user_id'] ), $fname );
} elseif ( $table == $this->tableName( 'image' ) ) {
- $this->update( 'oldimage', array( 'oi_name' => 0 ), array( 'oi_name' => $conds['img_name'] ), $fname );
+ $this->update( 'oldimage', array( 'oi_name' => 0 ),
+ array( 'oi_name' => $conds['img_name'] ), $fname );
}
return parent::delete( $table, $conds, $fname );
}
function hasConstraint( $name ) {
- $SQL = "SELECT 1 FROM pg_catalog.pg_constraint c, pg_catalog.pg_namespace n WHERE c.connamespace = n.oid AND conname = '" .
- pg_escape_string( $this->mConn, $name ) . "' AND n.nspname = '" . pg_escape_string( $this->mConn, $this->getCoreSchema() ) . "'";
+ $SQL = "SELECT 1 FROM pg_catalog.pg_constraint c, pg_catalog.pg_namespace n " .
+ "WHERE c.connamespace = n.oid AND conname = '" .
+ pg_escape_string( $this->mConn, $name ) . "' AND n.nspname = '" .
+ pg_escape_string( $this->mConn, $this->getCoreSchema() ) . "'";
$res = $this->doQuery( $SQL );
return $this->numRows( $res );
function open( $server, $user, $password, $dbName ) {
# Test for Postgres support, to avoid suppressed fatal error
if ( !function_exists( 'pg_connect' ) ) {
- throw new DBConnectionError( $this, "Postgres functions missing, have you compiled PHP with the --with-pgsql option?\n (Note: if you recently installed PHP, you may need to restart your webserver and database)\n" );
+ throw new DBConnectionError(
+ $this,
+ "Postgres functions missing, have you compiled PHP with the --with-pgsql\n" .
+ "option? (Note: if you recently installed PHP, you may need to restart your\n" .
+ "webserver and database)\n"
+ );
}
global $wgDBport;
if ( !$this->mConn ) {
wfDebug( "DB connection error\n" );
- wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
+ wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " .
+ substr( $password, 0, 3 ) . "...\n" );
wfDebug( $this->lastError() . "\n" );
throw new DBConnectionError( $this, str_replace( "\n", ' ', $phpError ) );
}
PGSQL_DIAG_SOURCE_FUNCTION
);
foreach ( $diags as $d ) {
- wfDebug( sprintf( "PgSQL ERROR(%d): %s\n", $d, pg_result_error_field( $this->mLastResult, $d ) ) );
+ wfDebug( sprintf( "PgSQL ERROR(%d): %s\n",
+ $d, pg_result_error_field( $this->mLastResult, $d ) ) );
}
}
# @todo hashar: not sure if the following test really trigger if the object
# fetching failed.
if ( pg_last_error( $this->mConn ) ) {
- throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) );
+ throw new DBUnexpectedError(
+ $this,
+ 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) )
+ );
}
return $row;
$row = pg_fetch_array( $res );
wfRestoreWarnings();
if ( pg_last_error( $this->mConn ) ) {
- throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) );
+ throw new DBUnexpectedError(
+ $this,
+ 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) )
+ );
}
return $row;
$n = pg_num_rows( $res );
wfRestoreWarnings();
if ( pg_last_error( $this->mConn ) ) {
- throw new DBUnexpectedError( $this, 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) ) );
+ throw new DBUnexpectedError(
+ $this,
+ 'SQL error: ' . htmlspecialchars( pg_last_error( $this->mConn ) )
+ );
}
return $n;
* Takes same arguments as Database::select()
* @return int
*/
- function estimateRowCount( $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array() ) {
+ function estimateRowCount( $table, $vars = '*', $conds = '',
+ $fname = __METHOD__, $options = array()
+ ) {
$options['EXPLAIN'] = true;
$res = $this->select( $table, $vars, $conds, $fname, $options );
$rows = -1;
/**
* INSERT SELECT wrapper
* $varMap must be an associative array of the form array( 'dest1' => 'source1', ...)
- * Source items may be literals rather then field names, but strings should be quoted with Database::addQuotes()
+ * Source items may be literals rather then field names, but strings should
+ * be quoted with Database::addQuotes()
* $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)?
$newName = $this->addIdentifierQuotes( $newName );
$oldName = $this->addIdentifierQuotes( $oldName );
- return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName (LIKE $oldName INCLUDING DEFAULTS)", $fname );
+ return $this->query( 'CREATE ' . ( $temporary ? 'TEMPORARY ' : '' ) . " TABLE $newName " .
+ "(LIKE $oldName INCLUDING DEFAULTS)", $fname );
}
function listTables( $prefix = null, $fname = __METHOD__ ) {
}
} else {
$this->mCoreSchema = $this->getCurrentSchema();
- wfDebug( "Schema \"" . $desired_schema . "\" not found, using current \"" . $this->mCoreSchema . "\"\n" );
+ wfDebug( "Schema \"" . $desired_schema . "\" not found, using current \"" .
+ $this->mCoreSchema . "\"\n" );
}
/* Commit SET otherwise it will be rollbacked on error or IGNORE SELECT */
$this->commit( __METHOD__ );
}
/**
- * 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
+ * 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
* @return bool
* 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 SELECT foo FROM dbname.table
- * @param string $file database file name. If omitted, will be generated using $name and $wgSQLiteDataDir
+ * @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
+ * using $name and $wgSQLiteDataDir
* @param string $fname calling function name
*
* @return ResultWrapper
* @return string User-friendly database information
*/
public function getServerInfo() {
- return wfMessage( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() )->text();
+ return wfMessage( self::getFulltextSearchModule()
+ ? 'sqlite-has-fts'
+ : 'sqlite-no-fts', $this->getServerVersion() )->text();
}
/**
// INT -> INTEGER
$s = preg_replace( '/\b(tiny|small|medium|big|)int(\s*\(\s*\d+\s*\)|\b)/i', 'INTEGER', $s );
// floating point types -> REAL
- $s = preg_replace( '/\b(float|double(\s+precision)?)(\s*\(\s*\d+\s*(,\s*\d+\s*)?\)|\b)/i', 'REAL', $s );
+ $s = preg_replace(
+ '/\b(float|double(\s+precision)?)(\s*\(\s*\d+\s*(,\s*\d+\s*)?\)|\b)/i',
+ 'REAL',
+ $s
+ );
// varchar -> TEXT
$s = preg_replace( '/\b(var)?char\s*\(.*?\)/i', 'TEXT', $s );
// TEXT normalization
* @return bool|ResultWrapper
*/
function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = __METHOD__ ) {
- $res = $this->query( "SELECT sql FROM sqlite_master WHERE tbl_name=" . $this->addQuotes( $oldName ) . " AND type='table'", $fname );
+ $res = $this->query( "SELECT sql FROM sqlite_master WHERE tbl_name=" .
+ $this->addQuotes( $oldName ) . " AND type='table'", $fname );
$obj = $this->fetchObject( $res );
if ( !$obj ) {
throw new MWException( "Couldn't retrieve structure for table $oldName" );
}
$sql = $obj->sql;
- $sql = preg_replace( '/(?<=\W)"?' . preg_quote( trim( $this->addIdentifierQuotes( $oldName ), '"' ) ) . '"?(?=\W)/', $this->addIdentifierQuotes( $newName ), $sql, 1 );
+ $sql = preg_replace(
+ '/(?<=\W)"?' . preg_quote( trim( $this->addIdentifierQuotes( $oldName ), '"' ) ) . '"?(?=\W)/',
+ $this->addIdentifierQuotes( $newName ),
+ $sql,
+ 1
+ );
if ( $temporary ) {
if ( preg_match( '/^\\s*CREATE\\s+VIRTUAL\\s+TABLE\b/i', $sql ) ) {
wfDebug( "Table $oldName is virtual, can't create a temporary duplicate.\n" );
}
/**
- * Used by DatabaseBase::buildLike() to represent characters that have special meaning in SQL LIKE clauses
- * and thus need no escaping. Don't instantiate it manually, use DatabaseBase::anyChar() and anyString() instead.
+ * Used by DatabaseBase::buildLike() to represent characters that have special
+ * meaning in SQL LIKE clauses and thus need no escaping. Don't instantiate it
+ * manually, use DatabaseBase::anyChar() and anyString() instead.
*/
class LikeMatch {
private $str;
* * array
* * blob
*
- * TODO: get rid of the id field. Every row instance needs to have
- * one so this is just causing hassle at various locations by requiring an extra check for field name.
+ * @todo Get rid of the id field. Every row instance needs to have one so
+ * this is just causing hassle at various locations by requiring an extra
+ * check for field name.
*
* @since 1.20
*
*
* @since 1.20
*
- * @return String|bool The target wiki, in a form that LBFactory understands (or false if the local wiki is used)
+ * @return String|bool The target wiki, in a form that LBFactory
+ * understands (or false if the local wiki is used)
*/
public function getTargetWiki();
/**
* Set the ID of the any foreign wiki to use as a target for database operations
*
- * @param string|bool $wiki The target wiki, in a form that LBFactory understands (or false if the local wiki shall be used)
+ * @param string|bool $wiki The target wiki, in a form that LBFactory
+ * understands (or false if the local wiki shall be used)
*
* @since 1.20
*/
*/
class DBAccessError extends MWException {
function __construct() {
- parent::__construct( "Mediawiki tried to access the database via wfGetDB(). This is not allowed." );
+ parent::__construct( "Mediawiki tried to access the database via wfGetDB(). " .
+ "This is not allowed." );
}
}
* Configuration:
* sectionsByDB A map of database names to section names
*
- * sectionLoads A 2-d map. For each section, gives a map of server names to load ratios.
- * For example: array( 'section1' => array( 'db1' => 100, 'db2' => 100 ) )
+ * sectionLoads A 2-d map. For each section, gives a map of server names to
+ * load ratios. For example:
+ * array(
+ * 'section1' => array(
+ * 'db1' => 100,
+ * 'db2' => 100
+ * )
+ * )
*
- * serverTemplate A server info associative array as documented for $wgDBservers. The host,
- * hostName and load entries will be overridden.
+ * serverTemplate A server info associative array as documented for $wgDBservers.
+ * The host, hostName and load entries will be overridden.
*
- * groupLoadsBySection A 3-d map giving server load ratios for each section and group. For example:
- * array( 'section1' => array( 'group1' => array( 'db1' => 100, 'db2' => 100 ) ) )
+ * groupLoadsBySection A 3-d map giving server load ratios for each section and group.
+ * For example:
+ * array(
+ * 'section1' => array(
+ * 'group1' => array(
+ * 'db1' => 100,
+ * 'db2' => 100
+ * )
+ * )
+ * )
*
* groupLoadsByDB A 3-d map giving server load ratios by DB name.
*
*
* externalLoads A map of external storage cluster name to server load map
*
- * externalTemplateOverrides A set of server info keys overriding serverTemplate for external storage
+ * externalTemplateOverrides A set of server info keys overriding serverTemplate for external
+ * storage
*
- * templateOverridesByServer A 2-d map overriding serverTemplate and externalTemplateOverrides on a
- * server-by-server basis. Applies to both core and external storage.
+ * templateOverridesByServer A 2-d map overriding serverTemplate and
+ * externalTemplateOverrides on a server-by-server basis. Applies
+ * to both core and external storage.
*
* templateOverridesByCluster A 2-d map overriding the server info by external storage cluster
*
* masterTemplateOverrides An override array for all master servers.
*
- * readOnlyBySection A map of section name to read-only message. Missing or false for read/write.
+ * readOnlyBySection A map of section name to read-only message.
+ * Missing or false for read/write.
*
* @ingroup Database
*/
if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
$groupLoads = $this->groupLoadsByDB[$dbName];
}
+
if ( isset( $this->groupLoadsBySection[$section] ) ) {
$groupLoads = array_merge_recursive( $groupLoads, $this->groupLoadsBySection[$section] );
}
- return $this->newLoadBalancer( $this->serverTemplate, $this->sectionLoads[$section], $groupLoads );
+ return $this->newLoadBalancer(
+ $this->serverTemplate,
+ $this->sectionLoads[$section],
+ $groupLoads
+ );
}
/**
if ( $i == DB_LAST ) {
wfProfileOut( __METHOD__ );
- throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' );
+ throw new MWException( 'Attempt to call ' . __METHOD__ .
+ ' with deprecated server index DB_LAST' );
} elseif ( $i === null || $i === false ) {
wfProfileOut( __METHOD__ );
- throw new MWException( 'Attempt to call ' . __METHOD__ . ' with invalid server index' );
+ throw new MWException( 'Attempt to call ' . __METHOD__ .
+ ' with invalid server index' );
}
if ( $wiki === wfWikiID() ) {
return;
}
if ( $this->mConns['foreignUsed'][$serverIndex][$wiki] !== $conn ) {
- throw new MWException( __METHOD__ . ": connection not found, has the connection been freed already?" );
+ throw new MWException( __METHOD__ . ": connection not found, has " .
+ "the connection been freed already?" );
}
$conn->setLBInfo( 'foreignPoolRefCount', --$refCount );
if ( $refCount <= 0 ) {
}
/**
- * Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist
+ * Sets the server info structure for the given index. Entry at index $i
+ * is created if it doesn't exist
* @param $i
* @param $serverInfo
*/
/**
* Before removal of an object happens, @see beforeRemove gets called.
- * This method loads the fields of which the names have been returned by this one (or all fields if null is returned).
- * This allows for loading info needed after removal to get rid of linked data and the like.
+ * This method loads the fields of which the names have been returned by
+ * this one (or all fields if null is returned). This allows for loading
+ * info needed after removal to get rid of linked data and the like.
*
* @since 1.20
*
* @param string|null $rowClass
* @param string $fieldPrefix
*/
- public function __construct( $tableName = '', array $fields = array(), array $defaults = array(), $rowClass = null, $fieldPrefix = '' ) {
+ public function __construct( $tableName = '', array $fields = array(),
+ array $defaults = array(), $rowClass = null, $fieldPrefix = ''
+ ) {
$this->tableName = $tableName;
$this->fields = $fields;
$this->defaults = $defaults;
}
if ( $setDefaults && $hasDefault ) {
- $default = is_array( $defaults[$field] ) ? implode( '|', $defaults[$field] ) : $defaults[$field];
+ $default = is_array( $defaults[$field] )
+ ? implode( '|', $defaults[$field] )
+ : $defaults[$field];
$params[$field][ApiBase::PARAM_DFLT] = $default;
}
}
}
/**
- * Set the database ID to use for read operations, use DB_XXX constants or an index to the load balancer setup.
+ * Set the database ID to use for read operations, use DB_XXX constants or
+ * an index to the load balancer setup.
*
* @param integer $db
*
*
* @since 1.20
*
- * @return String|bool The target wiki, in a form that LBFactory understands (or false if the local wiki is used)
+ * @return String|bool The target wiki, in a form that LBFactory understands
+ * (or false if the local wiki is used)
*/
public function getTargetWiki() {
return $this->wiki;
/**
* Set the ID of the any foreign wiki to use as a target for database operations
*
- * @param string|bool $wiki The target wiki, in a form that LBFactory understands (or false if the local wiki shall be used)
+ * @param string|bool $wiki The target wiki, in a form that LBFactory
+ * understands (or false if the local wiki shall be used)
*
* @since 1.20
*/