Go to the documentation of this file.
44 $this->cliMode = isset( $opts[
'cliMode'] ) ? $opts[
'cliMode'] :
true;
45 $this->connLogger = new \Psr\Log\NullLogger();
46 $this->queryLogger = new \Psr\Log\NullLogger();
47 $this->errorLogger =
function ( Exception
$e ) {
48 wfWarn( get_class(
$e ) .
": {$e->getMessage()}" );
50 $this->currentDomain = DatabaseDomain::newUnspecified();
59 $lastSqls = implode(
'; ', $this->lastSqls );
73 $this->nextResult =
$res;
78 $this->lastSqls[] = trim( preg_replace(
79 '/\s{2,}(?=FROM|WHERE|GROUP BY|ORDER BY|LIMIT)|(?<=SELECT|INSERT|UPDATE)\s{2,}/',
85 if ( substr(
$fname, 0, strlen( $this->testName ) ) !== $this->testName ) {
86 throw new MWException(
'function name does not start with test class. ' .
87 $fname .
' vs. ' . $this->testName .
'. ' .
88 'Please provide __METHOD__ to database methods.' );
94 return str_replace(
"'",
"\'",
$s );
110 $tableRaw = $this->
tableName( $table,
'raw' );
111 if ( isset( $this->mSessionTempTables[$tableRaw] ) ) {
117 return in_array( $table, (
array)$this->tablesExists );
122 return parent::nativeReplace( $table,
$rows,
$fname );
197 function ping( &$rtt =
null ) {
208 $this->nextResult = [];
210 return new FakeResultWrapper(
$res );
$testName
CLASS of the test suite, used to determine, if the function name is passed every time to query()
setUnionSupportsOrderAndLimit( $v)
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
fieldInfo( $table, $field)
getLastSqls()
Returns SQL queries grouped by '; ' Clear the list of queries that have been done so far.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Stub profiler that does nothing.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
nativeReplace( $table, $rows, $fname)
array $nextResult
List of row arrays.
tableExists( $table, $fname=__METHOD__)
unionSupportsOrderAndLimit()
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for tableName() and addQuotes(). You will need both of them. ------------------------------------------------------------------------ Basic query optimisation ------------------------------------------------------------------------ MediaWiki developers who need to write DB queries should have some understanding of databases and the performance issues associated with them. Patches containing unacceptably slow features will not be accepted. Unindexed queries are generally not welcome in MediaWiki
$tablesExists
Array of tables to be considered as existing by tableExist() Use setExistingTables() to alter.
setExistingTables( $tablesExists)
query( $sql, $fname='', $tempIgnore=false)
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
checkFunctionName( $fname)
Helper for testing the methods from the Database class.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
indexInfo( $table, $index, $fname='Database::indexInfo')
$lastSqls
Array of lastSqls passed to query(), This is an array since some methods in Database can do more than...
open( $server, $user, $password, $dbName)
$unionSupportsOrderAndLimit
Value to return from unionSupportsOrderAndLimit()
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
__construct( $testName, array $opts=[])
Class to handle database/prefix specification for IDatabase domains.
the array() calling protocol came about after MediaWiki 1.4rc1.