36 $this->cliMode = isset( $opts[
'cliMode'] ) ? $opts[
'cliMode'] :
true;
37 $this->connLogger = new \Psr\Log\NullLogger();
38 $this->queryLogger = new \Psr\Log\NullLogger();
40 wfWarn( get_class(
$e ) .
": {$e->getMessage()}" );
50 $lastSqls = implode(
'; ', $this->lastSqls );
64 $this->nextResult =
$res;
69 $this->lastSqls[] = trim( preg_replace(
70 '/\s{2,}(?=FROM|WHERE|GROUP BY|ORDER BY|LIMIT)|(?<=SELECT|INSERT|UPDATE)\s{2,}/',
76 if ( substr(
$fname, 0, strlen( $this->testName ) ) !== $this->testName ) {
77 throw new MWException(
'function name does not start with test class. ' .
78 $fname .
' vs. ' . $this->testName .
'. ' .
79 'Please provide __METHOD__ to database methods.' );
85 return str_replace(
"'",
"\'",
$s );
93 public function query( $sql,
$fname =
'', $tempIgnore =
false ) {
101 $tableRaw = $this->
tableName( $table,
'raw' );
102 if ( isset( $this->mSessionTempTables[$tableRaw] ) ) {
108 return in_array( $table, (
array)$this->tablesExists );
113 return parent::nativeReplace( $table, $rows,
$fname );
188 function ping( &$rtt = null ) {
199 $this->nextResult = [];
dataSeek($res, $row)
Change the position of the cursor in a result object.
fetchRow($res)
Fetch the next row from the given result object, in associative array form.
the array() calling protocol came about after MediaWiki 1.4rc1.
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
fetchObject($res)
Fetch the next row from the given result object, in object form.
insertId()
Get the inserted value of an auto-increment row.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
$testName
CLASS of the test suite, used to determine, if the function name is passed every time to query() ...
fieldInfo($table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
$lastSqls
Array of lastSqls passed to query(), This is an array since some methods in Database can do more than...
Stub profiler that does nothing.
checkFunctionName($fname)
open($server, $user, $password, $dbName)
Open a connection to the database.
tableName($name, $format= 'quoted')
Format a table name ready for use in constructing an SQL query.
isOpen()
Is a connection to the database open?
__construct($testName, array $opts=[])
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
affectedRows()
Get the number of rows affected by the last write query.
Helper class that detects high-contention DB queries via profiling calls.
Helper for testing the methods from the Database class.
numRows($res)
Get the number of rows in a result object.
setExistingTables($tablesExists)
array $nextResult
List of row arrays.
tableExists($table, $fname=__METHOD__)
Query whether a given table exists.
lastErrno()
Get the last error number.
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 local account $user
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)
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
getServerInfo()
A string describing the current software version, and possibly other details in a user-friendly way...
indexInfo($table, $index, $fname= 'Database::indexInfo')
numFields($res)
Get the number of fields in a result object.
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[http://www.mysql.com/ MySQL]"; Should at ...
query($sql, $fname= '', $tempIgnore=false)
Run an SQL query and return the result.
$tablesExists
Array of tables to be considered as existing by tableExist() Use setExistingTables() to alter...
getLastSqls()
Returns SQL queries grouped by '; ' Clear the list of queries that have been done so far...
lastError()
Get a description of the last error.
fieldName($res, $n)
Get a field name in a result object.