* @param string $format Output format, valid values are any function of a Message object
* @return string
*/
- public static function getCopyrightWarning( $title, $format = 'plain' ) {
+ public static function getCopyrightWarning( $title, $format = 'plain', $langcode = null ) {
global $wgRightsText;
if ( $wgRightsText ) {
$copywarnMsg = [ 'copyrightwarning',
// Allow for site and per-namespace customization of contribution/copyright notice.
Hooks::run( 'EditPageCopyrightWarning', [ $title, &$copywarnMsg ] );
+ $msg = call_user_func_array( 'wfMessage', $copywarnMsg )->title( $title );
+ if ( $langcode ) {
+ $msg->inLanguage( $langcode );
+ }
return "<div id=\"editpage-copywarn\">\n" .
- call_user_func_array( 'wfMessage', $copywarnMsg )->title( $title )->$format() . "\n</div>";
+ $msg->$format() . "\n</div>";
}
/**
protected function safeUnicodeOutput( $text ) {
return $this->checkUnicodeCompliantBrowser()
? $text
- : $this->makesafe( $text );
+ : $this->makeSafe( $text );
}
/**
*
* @param string $contents The raw HTML contents of the element: *not*
* escaped!
- * @param array $attrs Associative array of attributes, e.g., array(
- * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * @param array $attrs Associative array of attributes, e.g., [
+ * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for
* further documentation.
* @param string[] $modifiers classes to add to the button
* @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
*
* @param string $contents The raw HTML contents of the element: *not*
* escaped!
- * @param array $attrs Associative array of attributes, e.g., array(
- * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * @param array $attrs Associative array of attributes, e.g., [
+ * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for
* further documentation.
* @param string[] $modifiers classes to add to the button
* @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
* content model.
*
* @param string $element The element's name, e.g., 'a'
- * @param array $attribs Associative array of attributes, e.g., array(
- * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * @param array $attribs Associative array of attributes, e.g., [
+ * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for
* further documentation.
* @param string $contents The raw HTML contents of the element: *not*
* escaped!
* to the input array (currently per the HTML 5 draft as of 2009-09-06).
*
* @param string $element Name of the element, e.g., 'a'
- * @param array $attribs Associative array of attributes, e.g., array(
- * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * @param array $attribs Associative array of attributes, e.g., [
+ * 'href' => 'http://www.mediawiki.org/' ]. See expandAttributes() for
* further documentation.
* @return array An array of attributes functionally identical to $attribs
*/
/**
* Given an associative array of element attributes, generate a string
- * to stick after the element name in HTML output. Like array( 'href' =>
- * 'http://www.mediawiki.org/' ) becomes something like
+ * to stick after the element name in HTML output. Like [ 'href' =>
+ * 'http://www.mediawiki.org/' ] becomes something like
* ' href="http://www.mediawiki.org"'. Again, this is like
* Xml::expandAttributes(), but it implements some HTML-specific logic.
*
*
* @par Numerical array
* @code
- * Html::element( 'em', array(
- * 'class' => array( 'foo', 'bar' )
- * ) );
+ * Html::element( 'em', [
+ * 'class' => [ 'foo', 'bar' ]
+ * ] );
* // gives '<em class="foo bar"></em>'
* @endcode
*
* @par Associative array
* @code
- * Html::element( 'em', array(
- * 'class' => array( 'foo', 'bar', 'foo' => false, 'quux' => true )
- * ) );
+ * Html::element( 'em', [
+ * 'class' => [ 'foo', 'bar', 'foo' => false, 'quux' => true ]
+ * ] );
* // gives '<em class="bar quux"></em>'
* @endcode
*
- * @param array $attribs Associative array of attributes, e.g., array(
- * 'href' => 'http://www.mediawiki.org/' ). Values will be HTML-escaped.
+ * @param array $attribs Associative array of attributes, e.g., [
+ * 'href' => 'http://www.mediawiki.org/' ]. Values will be HTML-escaped.
* A value of false means to omit the attribute. For boolean attributes,
- * you can omit the key, e.g., array( 'checked' ) instead of
- * array( 'checked' => 'checked' ) or such.
+ * you can omit the key, e.g., [ 'checked' ] instead of
+ * [ 'checked' => 'checked' ] or such.
*
* @throws MWException If an attribute that doesn't allow lists is set to an array
* @return string HTML fragment that goes between element name and '>'
public static function expandAttributes( array $attribs ) {
$ret = '';
foreach ( $attribs as $key => $value ) {
- // Support intuitive array( 'checked' => true/false ) form
+ // Support intuitive [ 'checked' => true/false ] form
if ( $value === false || is_null( $value ) ) {
continue;
}
- // For boolean attributes, support array( 'foo' ) instead of
- // requiring array( 'foo' => 'meaningless' ).
+ // For boolean attributes, support [ 'foo' ] instead of
+ // requiring [ 'foo' => 'meaningless' ].
if ( is_int( $key ) && in_array( strtolower( $value ), self::$boolAttribs ) ) {
$key = $value;
}
}
} elseif ( $v ) {
// If the value is truthy but not a string this is likely
- // an array( 'foo' => true ), falsy values don't add strings
+ // an [ 'foo' => true ], falsy values don't add strings
$newValue[] = $k;
}
}
*
* @par Example:
* @code
- * Html::srcSet( array(
+ * Html::srcSet( [
* '1x' => 'standard.jpeg',
* '1.5x' => 'large.jpeg',
* '3x' => 'extra-large.jpeg',
- * ) );
+ * ] );
* // gives 'standard.jpeg 1x, large.jpeg 1.5x, extra-large.jpeg 2x'
* @endcode
*
/** @var Title Page to which history will be merged */
protected $dest;
- /** @var DatabaseBase Database that we are using */
+ /** @var IDatabase Database that we are using */
protected $dbw;
/** @var MWTimestamp Maximum timestamp that we can use (oldest timestamp of dest) */
$status = $newpage->doDeleteArticleReal(
$overwriteMessage,
/* $suppress */ false,
- $nt->getArticleId(),
+ $nt->getArticleID(),
/* $commit */ false,
$errs,
$user
* Output a standard error page
*
* showErrorPage( 'titlemsg', 'pagetextmsg' );
- * showErrorPage( 'titlemsg', 'pagetextmsg', array( 'param1', 'param2' ) );
+ * showErrorPage( 'titlemsg', 'pagetextmsg', [ 'param1', 'param2' ] );
* showErrorPage( 'titlemsg', $messageObject );
* showErrorPage( $titleMessageObject, $messageObject );
*
* @code
* echo $templateParser->processTemplate(
* 'ExampleTemplate',
- * array(
+ * [
* 'username' => $user->getName(),
* 'message' => 'Hello!'
- * )
+ * ]
* );
* @endcode
* @param string $templateName The name of the template
}
/**
- * @param DatabaseBase $connection
+ * @param Database $connection
* @throws MWException
*/
- private function reuseConnection( DatabaseBase $connection ) {
+ private function reuseConnection( Database $connection ) {
$this->loadBalancer->reuseConnection( $connection );
}
}
private function getWatchedItemsWithRCInfoQueryConds(
- DatabaseBase $db,
+ Database $db,
User $user,
array $options
) {
return $conds;
}
- private function getStartEndConds( DatabaseBase $db, array $options ) {
+ private function getStartEndConds( Database $db, array $options ) {
if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) {
return [];
}
return $conds;
}
- private function getUserRelatedConds( DatabaseBase $db, User $user, array $options ) {
+ private function getUserRelatedConds( Database $db, User $user, array $options ) {
if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) {
return [];
}
return $conds;
}
- private function getExtraDeletedPageLogEntryRelatedCond( DatabaseBase $db, User $user ) {
+ private function getExtraDeletedPageLogEntryRelatedCond( Database $db, User $user ) {
// LogPage::DELETED_ACTION hides the affected page, too. So hide those
// entirely from the watchlist, or someone could guess the title.
$bitmask = 0;
return '';
}
- private function getStartFromConds( DatabaseBase $db, array $options ) {
+ private function getStartFromConds( Database $db, array $options ) {
$op = $options['dir'] === self::DIR_OLDER ? '<' : '>';
list( $rcTimestamp, $rcId ) = $options['startFrom'];
$rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) );
);
}
- private function getWatchedItemsForUserQueryConds( DatabaseBase $db, User $user, array $options ) {
+ private function getWatchedItemsForUserQueryConds( Database $db, User $user, array $options ) {
$conds = [ 'wl_user' => $user->getId() ];
if ( $options['namespaceIds'] ) {
$conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
* Creates a query condition part for getting only items before or after the given link target
* (while ordering using $sort mode)
*
- * @param DatabaseBase $db
+ * @param Database $db
* @param LinkTarget $target
* @param string $op comparison operator to use in the conditions
* @return string
*/
- private function getFromUntilTargetConds( DatabaseBase $db, LinkTarget $target, $op ) {
+ private function getFromUntilTargetConds( Database $db, LinkTarget $target, $op ) {
return $db->makeList(
[
"wl_namespace $op " . $target->getNamespace(),
}
/**
- * @param DatabaseBase $connection
+ * @param Database $connection
*
* @throws MWException
*/
* @return array
*/
public function formatAuthenticationResponse( AuthenticationResponse $res ) {
- $params = $this->module->extractRequestParams();
-
$ret = [
'status' => $res->status,
];
*/
private function getFlags( $report ) {
$reportOnly = $this->getParameter( 'reportonly' );
- $userAgent = $this->getRequest()->getHeader( 'user-agent' );
$source = $this->getParameter( 'source' );
$falsePositives = $this->getConfig()->get( 'CSPFalsePositiveUrls' );
* @file
*/
-use MediaWiki\MediaWikiServices;
-
/**
* Query module to perform full text search within wiki titles and content
*
$vals = [
'namespace' => $result->getInterwikiNamespaceText(),
'title' => $title->getText(),
- 'url' => $title->getFullUrl(),
+ 'url' => $title->getFullURL(),
];
// Add item to results and see whether it fits
/**
* @codeCoverageIgnore
+ * @param array $data
+ * @return AuthenticationRequest|static
*/
public static function __set_state( $data ) {
if ( !isset( $data['label'] ) ) {
/**
* @codeCoverageIgnore
+ * @param array $data
+ * @return AuthenticationRequest|static
*/
public static function __set_state( $data ) {
$ret = new static( $data['domainList'] );
/**
* Try to reset the password
+ * @param \User $user
* @param AuthenticationRequest[] $reqs
* @return AuthenticationResponse
*/
}
$status = $this->checkPasswordValidity( $username, $req->password );
- if ( !$status->isOk() ) {
+ if ( !$status->isOK() ) {
// Fatal, can't log in
return AuthenticationResponse::newFail( $status->getMessage() );
}
* Construct a WHERE clause which will match all the given titles.
*
* @param string $prefix The appropriate table's field name prefix ('page', 'pl', etc)
- * @param IDatabase $db DatabaseBase object to use
+ * @param IDatabase $db DB object to use
* @return string|bool String with SQL where clause fragment, or false if no items.
*/
public function constructSet( $prefix, $db ) {
/**
* Generate the feed items given a row from the database, printing the feed.
- * @param object $rows DatabaseBase resource with recentchanges rows
+ * @param object $rows IDatabase resource with recentchanges rows
* @param ChannelFeed $feed
*/
public static function generateFeed( $rows, &$feed ) {
/**
* Generate the feed items given a row from the database.
- * @param object $rows DatabaseBase resource with recentchanges rows
+ * @param object $rows IDatabase resource with recentchanges rows
* @return array
*/
public static function buildItems( $rows ) {
* Handles selecting tags, and filtering.
* Needs $tables to be set up properly, so we can figure out which join conditions to use.
*
- * @param string|array $tables Table names, see DatabaseBase::select
- * @param string|array $fields Fields used in query, see DatabaseBase::select
- * @param string|array $conds Conditions used in query, see DatabaseBase::select
- * @param array $join_conds Join conditions, see DatabaseBase::select
+ * @param string|array $tables Table names, see Database::select
+ * @param string|array $fields Fields used in query, see Database::select
+ * @param string|array $conds Conditions used in query, see Database::select
+ * @param array $join_conds Join conditions, see Database::select
* @param array $options Options, see Database::select
* @param bool|string $filter_tag Tag to select on
*
<?php
use HtmlFormatter\HtmlFormatter;
-use MediaWiki\Logger\LoggerFactory;
/**
* Class allowing to explore structure of parsed wikitext.
* @file
*/
use Liuggio\StatsdClient\Factory\StatsdDataFactory;
-use MediaWiki\MediaWikiServices;
/**
* The simplest way of implementing IContextSource is to hold a RequestContext as a
*
* @since 1.21
*
- * @param DatabaseBase $db The database connection to release.
+ * @param Database $db The database connection to release.
*/
- protected function releaseConnection( DatabaseBase $db ) {
+ protected function releaseConnection( Database $db ) {
if ( $this->wiki !== false ) {
$loadBalancer = $this->getLoadBalancer();
$loadBalancer->reuseConnection( $db );
* UPDATE wrapper. Takes a condition array and a SET array.
*
* @param string $table Name of the table to UPDATE. This will be passed through
- * DatabaseBase::tableName().
+ * Database::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().
+ * Database::addQuotes().
*
* @param array $conds An array of conditions (WHERE). See
- * DatabaseBase::select() for the details of the format of
+ * Database::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__),
$this->mScrollableCursor = false;
try {
- $ret = $this->query( $sql );
+ $this->query( $sql );
} catch ( Exception $e ) {
$this->mScrollableCursor = true;
throw $e;
* @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().
+ * the documentation for $conds in Database::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
} else {
// Show any custom GUI message before the details
if ( $e instanceof MessageSpecifier ) {
- $wgOut->addHtml( Message::newFromSpecifier( $e )->escaped() );
+ $wgOut->addHTML( Message::newFromSpecifier( $e )->escaped() );
}
$wgOut->addHTML( self::getHTML( $e ) );
}
];
return function ( $index ) use ( $type, $params ) {
- return DatabaseBase::factory( $type, $params );
+ return Database::factory( $type, $params );
};
}
protected $archive;
- /** @var DatabaseBase */
+ /** @var IDatabase */
protected $db;
/**
} else {
$errors = $elements->getErrorsByType( $elementsType );
foreach ( $errors as &$error ) {
- // Input: array( 'message' => 'foo', 'errors' => array( 'a', 'b', 'c' ) )
- // Output: array( 'foo', 'a', 'b', 'c' )
+ // Input: [ 'message' => 'foo', 'errors' => [ 'a', 'b', 'c' ] ]
+ // Output: [ 'foo', 'a', 'b', 'c' ]
$error = array_merge( [ $error['message'] ], $error['params'] );
}
}
/**
* Constructor
*
- * @param DatabaseBase $db To perform updates on
+ * @param Database $db To perform updates on
* @param bool $shared Whether to perform updates on shared tables
* @param Maintenance $maintenance Maintenance object which created us
*/
- protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) {
+ protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) {
$this->db = $db;
$this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
$this->shared = $shared;
}
try {
- $db = DatabaseBase::factory( 'mssql', [
+ $db = Database::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
if ( !$status->isOK() ) {
return false;
}
- /** @var $conn DatabaseBase */
+ /** @var $conn Database */
$conn = $status->value;
// We need the server-level ALTER ANY LOGIN permission to create new accounts
}
try {
- DatabaseBase::factory( 'mssql', [
+ Database::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
if ( !$status->isOK() ) {
return $status;
}
- /** @var DatabaseBase $conn */
+ /** @var Database $conn */
$conn = $status->value;
$dbName = $this->getVar( 'wgDBname' );
$schemaName = $this->getVar( 'wgDBmwschema' );
public function openConnection() {
$status = Status::newGood();
try {
- $db = DatabaseBase::factory( 'mysql', [
+ $db = Database::factory( 'mysql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $this->getVar( '_InstallUser' ),
'password' => $this->getVar( '_InstallPassword' ),
if ( !$status->isOK() ) {
return false;
}
- /** @var $conn DatabaseBase */
+ /** @var $conn Database */
$conn = $status->value;
// Get current account name
if ( !$create ) {
// Test the web account
try {
- DatabaseBase::factory( 'mysql', [
+ Database::factory( 'mysql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $this->getVar( 'wgDBuser' ),
'password' => $this->getVar( 'wgDBpassword' ),
if ( !$status->isOK() ) {
return $status;
}
- /** @var DatabaseBase $conn */
+ /** @var Database $conn */
$conn = $status->value;
$dbName = $this->getVar( 'wgDBname' );
if ( !$conn->selectDB( $dbName ) ) {
if ( $this->getVar( '_CreateDBAccount' ) ) {
// Before we blindly try to create a user that already has access,
try { // first attempt to connect to the database
- DatabaseBase::factory( 'mysql', [
+ Database::factory( 'mysql', [
'host' => $server,
'user' => $dbUser,
'password' => $password,
protected function openConnectionWithParams( $user, $password, $dbName, $schema ) {
$status = Status::newGood();
try {
- $db = DatabaseBase::factory( 'postgres', [
+ $db = Database::factory( 'postgres', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
'password' => $password,
'dbname' => $db
];
- $conn = DatabaseBase::factory( 'postgres', $p );
+ $conn = Database::factory( 'postgres', $p );
} catch ( DBConnectionError $error ) {
$conn = false;
$status->fatal( 'config-pg-test-error', $db,
/**
* Recursive helper for canCreateObjectsForWebUser().
- * @param DatabaseBase $conn
+ * @param Database $conn
* @param int $targetMember Role ID of the member to look for
* @param int $group Role ID of the group to look for
* @param int $maxDepth Maximum recursive search depth
$dbName = $this->getVar( 'wgDBname' );
try {
# @todo FIXME: Need more sensible constructor parameters, e.g. single associative array
- $db = DatabaseBase::factory( 'sqlite', [ 'dbname' => $dbName, 'dbDirectory' => $dir ] );
+ $db = Database::factory( 'sqlite', [ 'dbname' => $dbName, 'dbDirectory' => $dir ] );
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
# Create the global cache DB
try {
- $conn = DatabaseBase::factory( 'sqlite', [ 'dbname' => 'wikicache', 'dbDirectory' => $dir ] );
+ $conn = Database::factory( 'sqlite', [ 'dbname' => 'wikicache', 'dbDirectory' => $dir ] );
# @todo: don't duplicate objectcache definition, though it's very simple
$sql =
<<<EOT
} elseif ( is_array( $this->dbServers[$lockDb] ) ) {
// Parameters to construct a new database connection
$config = $this->dbServers[$lockDb];
- $db = DatabaseBase::factory( $config['type'], $config );
+ $db = Database::factory( $config['type'], $config );
} else {
throw new UnexpectedValueException( "No server called '$lockDb'." );
}
/**
* Helper class that detects high-contention DB queries via profiling calls
*
- * This class is meant to work with a DatabaseBase object, which manages queries
+ * This class is meant to work with an IDatabase object, which manages queries
*
* @since 1.24
*/
* Either a short hexidecimal string if a transaction is active or ""
*
* @var string
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
protected $mTrxShortId = '';
/**
* point (possibly more up-to-date since the first SELECT defines the snapshot).
*
* @var float|null
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
private $mTrxTimestamp = null;
/** @var float Lag estimate at the time of BEGIN */
* Used to provide additional context for error reporting.
*
* @var string
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
private $mTrxFname = null;
/**
* Record if possible write queries were done in the last transaction started
*
* @var bool
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
private $mTrxDoneWrites = false;
/**
* Record if the current transaction was started implicitly due to DBO_TRX being set.
*
* @var bool
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
private $mTrxAutomatic = false;
/**
*/
private $mTrxAtomicLevels = [];
/**
- * Record if the current transaction was started implicitly by DatabaseBase::startAtomic
+ * Record if the current transaction was started implicitly by Database::startAtomic
*
* @var bool
*/
* @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()
+ * @see Database::select()
*/
protected function makeSelectOptions( $options ) {
$preLimitTail = $postLimitTail = '';
*
* @param array $options Associative array of options
* @return string
- * @see DatabaseBase::select()
+ * @see Database::select()
* @since 1.21
*/
protected function makeGroupByWithHaving( $options ) {
*
* @param array $options Associative array of options
* @return string
- * @see DatabaseBase::select()
+ * @see Database::select()
* @since 1.21
*/
protected function makeOrderBy( $options ) {
}
/**
- * Helper for DatabaseBase::insert().
+ * Helper for Database::insert().
*
* @param array $options
* @return string
}
/**
- * Make UPDATE options array for DatabaseBase::makeUpdateOptions
+ * Make UPDATE options array for Database::makeUpdateOptions
*
* @param array $options
* @return array
}
/**
- * Make UPDATE options for the DatabaseBase::update function
+ * Make UPDATE options for the Database::update function
*
- * @param array $options The options passed to DatabaseBase::update
+ * @param array $options The options passed to Database::update
* @return string
*/
protected function makeUpdateOptions( $options ) {
/**
* Issues the BEGIN command to the database server.
*
- * @see DatabaseBase::begin()
+ * @see Database::begin()
* @param string $fname
*/
protected function doBegin( $fname ) {
/**
* Issues the COMMIT command to the database server.
*
- * @see DatabaseBase::commit()
+ * @see Database::commit()
* @param string $fname
*/
protected function doCommit( $fname ) {
/**
* Issues the ROLLBACK command to the database server.
*
- * @see DatabaseBase::rollback()
+ * @see Database::rollback()
* @param string $fname
*/
protected function doRollback( $fname ) {
* necessary. Boolean values are passed through as is, to indicate success
* of write queries or failure.
*
- * Once upon a time, DatabaseBase::query() returned a bare MySQL result
+ * Once upon a time, Database::query() returned a bare MySQL result
* resource, and it was necessary to call this function to convert it to
* a wrapper. Nowadays, raw database objects are never exposed to external
* callers, so this is unnecessary in external code.
$p['schema'] = false;
$p['tablePrefix'] = '';
- return DatabaseBase::factory( 'sqlite', $p );
+ return Database::factory( 'sqlite', $p );
}
/**
* for use in field names (e.g. a.user_name).
*
* All of the table names given here are automatically run through
- * DatabaseBase::tableName(), which causes the table prefix (if any) to be
+ * Database::tableName(), which causes the table prefix (if any) to be
* added, and various other table name mappings to be performed.
*
* Do not use untrusted user input as a table name. Alias names should
* IDatabase::affectedRows().
*
* @param string $table Table name. This will be passed through
- * DatabaseBase::tableName().
+ * Database::tableName().
* @param array $a Array of rows to insert
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @param array $options Array of options
* UPDATE wrapper. Takes a condition array and a SET array.
*
* @param string $table Name of the table to UPDATE. This will be passed through
- * DatabaseBase::tableName().
+ * Database::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 IDatabase::addQuotes().
*
* @since 1.22
*
- * @param string $table Table name. This will be passed through DatabaseBase::tableName().
+ * @param string $table Table name. This will be passed through Database::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
*
* This can be an alternative to explicit startAtomic()/endAtomic() calls.
*
- * @see DatabaseBase::startAtomic
- * @see DatabaseBase::endAtomic
+ * @see Database::startAtomic
+ * @see Database::endAtomic
*
* @param string $fname Caller name (usually __METHOD__)
* @param callable $callback Callback that issues DB updates
<?php
/**
- * Used by DatabaseBase::buildLike() to represent characters that have special
+ * Used by Database::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.
+ * manually, use Database::anyChar() and anyString() instead.
*/
class LikeMatch {
/** @var string */
* @param string $fname
*/
function __construct( IDatabase $db, $error, $errno, $sql, $fname ) {
- if ( $db instanceof DatabaseBase && $db->wasConnectionError( $errno ) ) {
+ if ( $db instanceof Database && $db->wasConnectionError( $errno ) ) {
$message = "A connection error occured. \n" .
"Query: $sql\n" .
"Function: $fname\n" .
}
public function finalizeMasterChanges() {
- $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) {
+ $this->forEachOpenMasterConnection( function ( Database $conn ) {
// Any error should cause all DB transactions to be rolled back together
$conn->setTrxEndCallbackSuppression( false );
$conn->runOnTransactionPreCommitCallbacks();
$failures = [];
$this->forEachOpenMasterConnection(
- function ( DatabaseBase $conn ) use ( $fname, &$failures ) {
+ function ( Database $conn ) use ( $fname, &$failures ) {
$conn->setTrxEndCallbackSuppression( true );
try {
$conn->flushSnapshot( $fname );
public function runMasterPostTrxCallbacks( $type ) {
$e = null; // first exception
- $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) use ( $type, &$e ) {
+ $this->forEachOpenMasterConnection( function ( Database $conn ) use ( $type, &$e ) {
$conn->setTrxEndCallbackSuppression( false );
if ( $conn->writesOrCallbacksPending() ) {
// This happens if onTransactionIdle() callbacks leave callbacks on *another* DB
}
public function suppressTransactionEndCallbacks() {
- $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) {
+ $this->forEachOpenMasterConnection( function ( Database $conn ) {
$conn->setTrxEndCallbackSuppression( true );
} );
}
*/
private function getInstance( $prefix ) {
if ( !isset( $this->instances[$prefix] ) ) {
- throw new RunTimeException( "No service registered at prefix '{$prefix}'." );
+ throw new RuntimeException( "No service registered at prefix '{$prefix}'." );
}
if ( !( $this->instances[$prefix] instanceof VirtualRESTService ) ) {
return '';
}
$html = '';
- $html .= xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
+ $html .= Xml::label( wfMessage( 'log-action-filter-' . $types[0] )->text(),
'action-filter-' .$types[0] ) . "\n";
$select = new XmlSelect( 'subtype' );
$select->addOption( wfMessage( 'log-action-filter-all' )->text(), '' );
$select->addOption( wfMessage( $msgKey )->text(), $value );
}
$select->setDefault( $action );
- $html .= $select->getHtml();
+ $html .= $select->getHTML();
return $html;
}
*/
protected function transformImageMagickExt( $image, $params ) {
global $wgSharpenReductionThreshold, $wgSharpenParameter, $wgMaxAnimatedGifArea,
- $wgMaxInterlacingAreas, $wgJpegPixelFormat;
+ $wgJpegPixelFormat;
try {
$im = new Imagick();
/**
* Get an array structure that looks like this:
*
- * array(
- * 'visible' => array(
+ * [
+ * 'visible' => [
* 'Human-readable name' => 'Human readable value',
* ...
- * ),
- * 'collapsed' => array(
+ * ],
+ * 'collapsed' => [
* 'Human-readable name' => 'Human readable value',
* ...
- * )
- * )
+ * ]
+ * ]
* The UI will format this into a table where the visible fields are always
* visible, and the collapsed fields are optionally visible.
*
/**
* Gets configuration for the file warning message. Return value of
* the following structure:
- * array(
+ * [
* // Required, module with messages loaded for the client
* 'module' => 'example.filewarning.messages',
* // Required, array of names of messages
- * 'messages' => array(
+ * 'messages' => [
* // Required, main warning message
* 'main' => 'example-filewarning-main',
* // Optional, header for warning dialog
* 'footer' => 'example-filewarning-footer',
* // Optional, text for more-information link (see below)
* 'info' => 'example-filewarning-info',
- * ),
+ * ],
* // Optional, link for more information
* 'link' => 'http://example.com',
- * )
+ * ]
*
* Returns null if no warning is necessary.
* @param File $file
* Values can be one of client, im, custom, gd, imext, or an array
* of object, method-name to call that specific method.
*
- * If specifying a custom scaler command with array( Obj, method ),
+ * If specifying a custom scaler command with [ Obj, method ],
* the method in question should take 2 parameters, a File object,
* and a $scalerParams array with various options (See doTransform
* for what is in $scalerParams). On error it should return a
$this->logger->debug( __CLASS__ . ": connecting to $host" );
// Use a blank trx profiler to ignore expections as this is a cache
$info['trxProfiler'] = new TransactionProfiler();
- $db = DatabaseBase::factory( $type, $info );
+ $db = Database::factory( $type, $info );
$db->clearFlag( DBO_TRX );
} else {
$index = $this->replicaOnly ? DB_REPLICA : DB_MASTER;
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'categorylinks',
[ 'cl_to AS page_title, ' . NS_CATEGORY . ' AS page_namespace' ],
- // Have to do that since DatabaseBase::fieldNamesWithAlias treats numeric indexes
+ // Have to do that since Database::fieldNamesWithAlias treats numeric indexes
// as not being aliases, and NS_CATEGORY is numeric
[ 'cl_from' => $id ],
__METHOD__ );
protected $mProfiler;
/**
- * @var \MediaWiki\Linker\LinkRenderer
+ * @var LinkRenderer
*/
protected $mLinkRenderer;
}
/**
- * Get a \MediaWiki\Linker\LinkRenderer instance to make links with
+ * Get a LinkRenderer instance to make links with
*
* @since 1.28
- * @return \MediaWiki\Linker\LinkRenderer
+ * @return LinkRenderer
*/
public function getLinkRenderer() {
if ( !$this->mLinkRenderer ) {
* Change the form descriptor that determines how a field will look in the authentication form.
* Called from fieldInfoToFormDescriptor().
* @param AuthenticationRequest[] $requests
- * @param string $fieldInfo Field information array (union of all
+ * @param array $fieldInfo Field information array (union of all
* AuthenticationRequest::getFieldInfo() responses).
* @param array $formDescriptor HTMLForm descriptor. The special key 'weight' can be set to
* change the order of the fields.
/**
* Return custom message key.
* Allows subclasses to customize messages.
+ * @param string $defaultKey
* @return string
*/
protected function messageKey( $defaultKey ) {
* Maps an authentication field configuration for a single field (as returned by
* AuthenticationRequest::getFieldInfo()) to a HTMLForm field descriptor.
* @param array $singleFieldInfo
+ * @param string $fieldName
* @return array
*/
protected static function mapSingleFieldInfo( $singleFieldInfo, $fieldName ) {
$session->remove( 'specialPreferencesSaveSuccess' );
$out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
- $out->addHtml(
+ $out->addHTML(
Html::rawElement(
'div',
[
'high' => 'MAX( cl_timestamp )'
],
[
- 'cl_to' => $this->category->getDBKey(),
+ 'cl_to' => $this->category->getDBkey(),
],
__METHOD__,
[
if ( $request->getCheck( 'success' ) && $this->mFetchedUser !== null ) {
$out->addModules( [ 'mediawiki.special.userrights' ] );
$out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
- $out->addHtml(
+ $out->addHTML(
Html::rawElement(
'div',
[
$this->config['tidyCompat'] && !$isComment &&
$this->currentNode->isA( BalanceSets::$tidyPWrapSet )
) {
- $this->insertHTMLELement( 'mw:p-wrap', [] );
+ $this->insertHTMLElement( 'mw:p-wrap', [] );
return $this->insertText( $value );
} else {
$this->currentNode->appendChild( $value );
* protected against race conditions using a compare-and-set (CAS) mechanism
* based on comparing $this->mTouched with the user_touched field.
*
- * @param DatabaseBase $db
- * @param array $conditions WHERE conditions for use with DatabaseBase::update
- * @return array WHERE conditions for use with DatabaseBase::update
+ * @param Database $db
+ * @param array $conditions WHERE conditions for use with Database::update
+ * @return array WHERE conditions for use with Database::update
*/
- protected function makeUpdateConditions( DatabaseBase $db, array $conditions ) {
+ protected function makeUpdateConditions( Database $db, array $conditions ) {
if ( $this->mTouched ) {
// CAS check: only update if the row wasn't changed sicne it was loaded.
$conditions['user_touched'] = $db->timestamp( $this->mTouched );
/**
* Takes a number of seconds and returns an array with a set of corresponding intervals.
- * For example 65 will be turned into array( minutes => 1, seconds => 5 ).
+ * For example 65 will be turned into [ minutes => 1, seconds => 5 ].
*
* @since 1.20
*
// -{zh-hans:<span style="font-size:120%;">xxx</span>;zh-hant:\
// <span style="font-size:120%;">yyy</span>;}-
// we should split it as:
- // array(
+ // [
// [0] => 'zh-hans:<span style="font-size:120%;">xxx</span>'
// [1] => 'zh-hant:<span style="font-size:120%;">yyy</span>'
// [2] => ''
- // )
+ // ]
$pat = '/;\s*(?=';
foreach ( $this->mVariants as $variant ) {
// zh-hans:xxx;zh-hant:yyy
*/
function commafy( $_ ) {
/* NO-op for Khmer. Cannot use
- * $separatorTransformTable = array( ',' => '' )
+ * $separatorTransformTable = [ ',' => '' ]
* That would break when parsing and doing strstr '' => 'foo';
*/
return $_;
*/
function commafy( $_ ) {
/* NO-op. Cannot use
- * $separatorTransformTable = array( ',' => '' )
+ * $separatorTransformTable = [ ',' => '' ]
* That would break when parsing and doing strstr '' => 'foo';
*/
return $_;
* Mapping NS_xxx to array of GENDERKEY to alias.
* Example:
* @code
- * $namespaceGenderAliases = array(
- * NS_USER => array( 'male' => 'Male_user', 'female' => 'Female_user' ),
- * );
+ * $namespaceGenderAliases = [
+ * NS_USER => [ 'male' => 'Male_user', 'female' => 'Female_user' ],
+ * ];
* @endcode
*/
$namespaceGenderAliases = [];
} else {
$where = [];
}
- $i = 0;
$this->output( "Removing empty categories without description pages...\n" );
while ( true ) {
$user = $dbw->tableName( 'user' );
$revision = $dbw->tableName( 'revision' );
- $dbver = $dbw->getServerVersion();
-
// Autodetect mode...
if ( $this->hasOption( 'background' ) ) {
$backgroundMode = true;
if ( !strcmp( $runMode, 'php' ) ) {
print "<?php\n";
- print '$dupeMessages = array(' . "\n";
+ print '$dupeMessages = [' . "\n";
}
foreach ( $wgMessages[$langCodeC] as $key => $value ) {
foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
}
}
if ( !strcmp( $runMode, 'php' ) ) {
- print ");\n";
+ print "];\n";
}
if ( !strcmp( $runMode, 'text' ) ) {
if ( $count == 1 ) {
continue;
}
- $this->output( "OK\n\$digitTransformTable = array(\n" );
+ $this->output( "OK\n\$digitTransformTable = [\n" );
foreach ( $digitTransformTable as $latin => $translation ) {
$htmlent = utf8ToHexSequence( $translation );
$this->output( "'$latin' => '$translation', # &#x$htmlent;\n" );
}
- $this->output( ");\n" );
+ $this->output( "];\n" );
}
}
}
public $minLength = 0;
public $maxLength = 20;
public $maxTemplates = 5;
- // public $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' );
+ // public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ];
public $entryPoints = [ 'testSrvus', 'testPst', 'testPreprocess' ];
public $verbose = false;
$blockEnd = $start + $this->mBatchSize - 1;
$dbw = $this->getDB( DB_MASTER );
- $mainContext = RequestContext::getMain();
// Go through each page and save the output
while ( $blockEnd <= $end ) {
// Get the pages
if ( $text === false ) {
$this->error( "\nError, unable to get text in old_id $oldid" );
- # $dbw->delete( 'old', array( 'old_id' => $oldid ) );
+ # $dbw->delete( 'old', [ 'old_id' => $oldid ] );
}
if ( $extdb == "" && $j == 0 ) {
/**
* Our connection to the database
- * @var DatabaseBase
+ * @var Database
*/
private $db;
/**
* Primary database
*
- * @var DatabaseBase
+ * @var Database
* @since 1.18
*/
protected $db;
* Clones all tables in the given database (whatever database that connection has
* open), to versions with the test prefix.
*
- * @param DatabaseBase $db Database to use
+ * @param Database $db Database to use
* @param string $prefix Prefix to use for test tables
* @return bool True if tables were cloned, false if only the prefix was changed
*/
- protected static function setupDatabaseWithTestPrefix( DatabaseBase $db, $prefix ) {
+ protected static function setupDatabaseWithTestPrefix( Database $db, $prefix ) {
$tablesCloned = self::listTables( $db );
$dbClone = new CloneDatabase( $db, $tablesCloned, $prefix );
$dbClone->useTemporaryTables( self::$useTemporaryTables );
* @note this method only works when first called. Subsequent calls have no effect,
* even if using different parameters.
*
- * @param DatabaseBase $db The database connection
+ * @param Database $db The database connection
* @param string $prefix The prefix to use for the new table set (aka schema).
*
* @throws MWException If the database table prefix is already $prefix
*/
- public static function setupTestDB( DatabaseBase $db, $prefix ) {
+ public static function setupTestDB( Database $db, $prefix ) {
if ( self::$dbSetup ) {
return;
}
}
// TODO: the below should be re-written as soon as LBFactory, LoadBalancer,
- // and DatabaseBase no longer use global state.
+ // and Database no longer use global state.
self::$dbSetup = true;
* Gets master database connections for all of the ExternalStoreDB
* stores configured in $wgDefaultExternalStore.
*
- * @return DatabaseBase[] Array of DatabaseBase master connections
+ * @return Database[] Array of Database master connections
*/
protected static function getExternalStoreDatabaseConnections() {
if ( strpos( $url, 'DB://' ) === 0 ) {
list( $proto, $cluster ) = explode( '://', $url, 2 );
// Avoid getMaster() because setupDatabaseWithTestPrefix()
- // requires DatabaseBase instead of plain DBConnRef/IDatabase
+ // requires Database instead of plain DBConnRef/IDatabase
$lb = $externalStoreDB->getLoadBalancer( $cluster );
$dbw = $lb->getConnection( DB_MASTER );
$dbws[] = $dbw;
/**
* Empty all tables so they can be repopulated for tests
*
- * @param DatabaseBase $db|null Database to reset
+ * @param Database $db|null Database to reset
* @param array $tablesUsed Tables to reset
*/
private function resetDB( $db, $tablesUsed ) {
/**
* @since 1.18
*
- * @param DatabaseBase $db
+ * @param Database $db
*
* @return array
*/
- public static function listTables( DatabaseBase $db ) {
+ public static function listTables( Database $db ) {
$prefix = $db->tablePrefix();
$tables = $db->listTables( $prefix, __METHOD__ );
class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
/**
- * @return PHPUnit_Framework_MockObject_MockObject|DatabaseBase
+ * @return PHPUnit_Framework_MockObject_MockObject|Database
*/
private function getMockDb() {
- $mock = $this->getMockBuilder( DatabaseBase::class )
+ $mock = $this->getMockBuilder( Database::class )
->disableOriginalConstructor()
->getMock();
}
/**
- * Given array( array('x' => 10, 'y' => 20), array( 'x' => 30, y=> 5 ) )
+ * Given [ [ 'x' => 10, 'y' => 20 ], [ 'x' => 30, y=> 5 ] ]
* returns "10,20 30,5"
* Useful for SVG and imagemagick command line arguments
* @param array $shape Array of arrays, each array containing x & y keys mapped to numeric values
/**
* Get an array of random pairs of random words, like
- * array( array( 'foo', 'bar' ), array( 'quux', 'baz' ) );
+ * [ [ 'foo', 'bar' ], [ 'quux', 'baz' ] ];
*
* @param int $number Number of pairs
* @return array Two-element arrays
* Fake class around abstract class so we can call concrete methods.
*/
class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
- // From DatabaseBase
+ // From Database
function __construct() {
$this->profiler = new ProfilerStub( [] );
$this->trxProfiler = new TransactionProfiler();
}
- // From interface DatabaseType
function insertId() {
}
/**
* @dataProvider provideSelect
- * @covers DatabaseBase::select
+ * @covers Database::select
*/
public function testSelect( $sql, $sqlText ) {
$this->database->select(
/**
* @dataProvider provideUpdate
- * @covers DatabaseBase::update
+ * @covers Database::update
*/
public function testUpdate( $sql, $sqlText ) {
$this->database->update(
/**
* @dataProvider provideDelete
- * @covers DatabaseBase::delete
+ * @covers Database::delete
*/
public function testDelete( $sql, $sqlText ) {
$this->database->delete(
/**
* @dataProvider provideUpsert
- * @covers DatabaseBase::upsert
+ * @covers Database::upsert
*/
public function testUpsert( $sql, $sqlText ) {
$this->database->upsert(
/**
* @dataProvider provideDeleteJoin
- * @covers DatabaseBase::deleteJoin
+ * @covers Database::deleteJoin
*/
public function testDeleteJoin( $sql, $sqlText ) {
$this->database->deleteJoin(
/**
* @dataProvider provideInsert
- * @covers DatabaseBase::insert
+ * @covers Database::insert
*/
public function testInsert( $sql, $sqlText ) {
$this->database->insert(
/**
* @dataProvider provideInsertSelect
- * @covers DatabaseBase::insertSelect
+ * @covers Database::insertSelect
*/
public function testInsertSelect( $sql, $sqlTextNative, $sqlSelect, $sqlInsert ) {
$this->database->insertSelect(
/**
* @dataProvider provideReplace
- * @covers DatabaseBase::replace
+ * @covers Database::replace
*/
public function testReplace( $sql, $sqlText ) {
$this->database->replace(
/**
* @dataProvider provideNativeReplace
- * @covers DatabaseBase::nativeReplace
+ * @covers Database::nativeReplace
*/
public function testNativeReplace( $sql, $sqlText ) {
$this->database->nativeReplace(
/**
* @dataProvider provideConditional
- * @covers DatabaseBase::conditional
+ * @covers Database::conditional
*/
public function testConditional( $sql, $sqlText ) {
$this->assertEquals( trim( $this->database->conditional(
/**
* @dataProvider provideBuildConcat
- * @covers DatabaseBase::buildConcat
+ * @covers Database::buildConcat
*/
public function testBuildConcat( $stringList, $sqlText ) {
$this->assertEquals( trim( $this->database->buildConcat(
/**
* @dataProvider provideBuildLike
- * @covers DatabaseBase::buildLike
+ * @covers Database::buildLike
*/
public function testBuildLike( $array, $sqlText ) {
$this->assertEquals( trim( $this->database->buildLike(
/**
* @dataProvider provideUnionQueries
- * @covers DatabaseBase::unionQueries
+ * @covers Database::unionQueries
*/
public function testUnionQueries( $sql, $sqlText ) {
$this->assertEquals( trim( $this->database->unionQueries(
}
/**
- * @covers DatabaseBase::commit
+ * @covers Database::commit
*/
public function testTransactionCommit() {
$this->database->begin( __METHOD__ );
}
/**
- * @covers DatabaseBase::rollback
+ * @covers Database::rollback
*/
public function testTransactionRollback() {
$this->database->begin( __METHOD__ );
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testDropTable() {
$this->database->setExistingTables( [ 'table' ] );
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testDropNonExistingTable() {
$this->assertFalse(
/**
* @dataProvider provideMakeList
- * @covers DatabaseBase::makeList
+ * @covers Database::makeList
*/
public function testMakeList( $list, $mode, $sqlText ) {
$this->assertEquals( trim( $this->database->makeList(
$p['dbFilePath'] = ':memory:';
$p['schema'] = false;
- return DatabaseBase::factory( 'SqliteMock', $p );
+ return Database::factory( 'SqliteMock', $p );
}
function query( $sql, $fname = '', $tempIgnore = false ) {
/**
* @group Database
- * @group DatabaseBase
+ * @group Database
*/
class DatabaseTest extends MediaWikiTestCase {
/**
- * @var DatabaseBase
+ * @var Database
*/
protected $db;
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testAddQuotesNull() {
$check = "NULL";
}
/**
- * @covers DatabaseBase::setTransactionListener()
+ * @covers Database::setTransactionListener()
*/
public function testTransactionListener() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::flushSnapshot()
+ * @covers Database::flushSnapshot()
*/
public function testFlushSnapshot() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::getFlag(
- * @covers DatabaseBase::setFlag()
- * @covers DatabaseBase::restoreFlags()
+ * @covers Database::getFlag(
+ * @covers Database::setFlag()
+ * @covers Database::restoreFlags()
*/
public function testFlagSetting() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::tablePrefix()
- * @covers DatabaseBase::dbSchema()
+ * @covers Database::tablePrefix()
+ * @covers Database::dbSchema()
*/
public function testMutators() {
$old = $this->db->tablePrefix();
<?php
/**
- * Helper for testing the methods from the DatabaseBase class
+ * Helper for testing the methods from the Database class
* @since 1.22
*/
-class DatabaseTestHelper extends DatabaseBase {
+class DatabaseTestHelper extends Database {
/**
* __CLASS__ of the test suite,
/**
* Array of lastSqls passed to query(),
- * This is an array since some methods in DatabaseBase can do more than one
+ * This is an array since some methods in Database can do more than one
* query. Cleared when calling getLastSqls().
*/
protected $lastSqls = [];
return false;
}
- function indexInfo( $table, $index, $fname = 'DatabaseBase::indexInfo' ) {
+ function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
return false;
}
);
unset( $db );
- /** @var DatabaseBase $db */
+ /** @var Database $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
$lb->reuseConnection( $db ); // don't care
$factory = $this->newLBFactoryMulti(
[ 'localDomain' => $dbname ], [ 'dbname' => $dbname ] );
$lb = $factory->getMainLB();
- /** @var DatabaseBase $db */
+ /** @var Database $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
$lb->reuseConnection( $db ); // don't care
}
}
-class FakeDatabase extends DatabaseBase {
+class FakeDatabase extends Database {
public $lastInsertTable;
public $lastInsertData;
* member variables.
* If no more rows are available, false is returned.
*
- * @param ResultWrapper|stdClass $res Object as returned from DatabaseBase::query(), etc.
+ * @param ResultWrapper|stdClass $res Object as returned from Database::query(), etc.
* @return stdClass|bool
* @throws DBUnexpectedError Thrown if the database returns an error
*/
* form. Fields are retrieved with $row['fieldname'].
* If no more rows are available, false is returned.
*
- * @param ResultWrapper $res Result object as returned from DatabaseBase::query(), etc.
+ * @param ResultWrapper $res Result object as returned from Database::query(), etc.
* @return array|bool
* @throws DBUnexpectedError Thrown if the database returns an error
*/
$db = $this->mockDb();
$db->expects( $this->once() )
->method( 'select' )
- // only testing second parameter of DatabaseBase::select
+ // only testing second parameter of Database::select
->with( 'some_table', $columns )
->will( $this->returnValue( new ArrayIterator( [] ) ) );
/**
* Slightly hackish to use reflection, but asserting different parameters
- * to consecutive calls of DatabaseBase::select in phpunit is error prone
+ * to consecutive calls of Database::select in phpunit is error prone
*
* @dataProvider provider_readerSelectConditions
*/
protected function consecutivelyReturnFromSelect( array $results ) {
$retvals = [];
foreach ( $results as $rows ) {
- // The DatabaseBase::select method returns iterators, so we do too.
+ // The Database::select method returns iterators, so we do too.
$retvals[] = $this->returnValue( new ArrayIterator( $rows ) );
}
}
protected function mockDb() {
- // Cant mock from DatabaseType or DatabaseBase, they dont
- // have the full gamut of methods
+ // @TODO: mock from Database
// FIXME: the constructor normally sets mAtomicLevels and mSrvCache
$databaseMysql = $this->getMockBuilder( 'DatabaseMysql' )
->disableOriginalConstructor()