32 } elseif ( count(
$conn ) >= 3 &&
$conn[self::FLD_DOMAIN] !==
false ) {
33 $this->params =
$conn;
35 throw new InvalidArgumentException(
"Missing lazy connection arguments." );
40 if ( $this->conn ===
null ) {
42 $this->conn = $this->lb->getConnection( $db, $groups, $wiki );
45 return call_user_func_array( [ $this->conn,
$name ], $arguments );
49 return $this->
__call( __FUNCTION__, func_get_args() );
53 return $this->
__call( __FUNCTION__, func_get_args() );
57 return $this->
__call( __FUNCTION__, func_get_args() );
61 return $this->
__call( __FUNCTION__, func_get_args() );
65 return $this->
__call( __FUNCTION__, func_get_args() );
69 return $this->
__call( __FUNCTION__, func_get_args() );
73 return $this->
__call( __FUNCTION__, func_get_args() );
77 return $this->
__call( __FUNCTION__, func_get_args() );
81 return $this->
__call( __FUNCTION__, func_get_args() );
85 return $this->
__call( __FUNCTION__, func_get_args() );
89 return $this->
__call( __FUNCTION__, func_get_args() );
93 return $this->
__call( __FUNCTION__, func_get_args() );
97 return $this->
__call( __FUNCTION__, func_get_args() );
101 return $this->
__call( __FUNCTION__, func_get_args() );
105 return $this->
__call( __FUNCTION__, func_get_args() );
109 return $this->
__call( __FUNCTION__, func_get_args() );
113 return $this->
__call( __FUNCTION__, func_get_args() );
117 return $this->
__call( __FUNCTION__, func_get_args() );
121 return $this->
__call( __FUNCTION__, func_get_args() );
125 return $this->
__call( __FUNCTION__, func_get_args() );
128 public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
129 return $this->
__call( __FUNCTION__, func_get_args() );
132 public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
133 return $this->
__call( __FUNCTION__, func_get_args() );
137 return $this->
__call( __FUNCTION__, func_get_args() );
141 return $this->
__call( __FUNCTION__, func_get_args() );
145 return $this->
__call( __FUNCTION__, func_get_args() );
149 if ( $this->conn ===
null ) {
155 return $this->
__call( __FUNCTION__, func_get_args() );
163 return $this->
__call( __FUNCTION__, func_get_args() );
166 public function open( $server, $user, $password, $dbName ) {
167 return $this->
__call( __FUNCTION__, func_get_args() );
171 return $this->
__call( __FUNCTION__, func_get_args() );
175 return $this->
__call( __FUNCTION__, func_get_args() );
179 return $this->
__call( __FUNCTION__, func_get_args() );
183 return $this->
__call( __FUNCTION__, func_get_args() );
187 return $this->
__call( __FUNCTION__, func_get_args() );
191 return $this->
__call( __FUNCTION__, func_get_args() );
195 return $this->
__call( __FUNCTION__, func_get_args() );
199 return $this->
__call( __FUNCTION__, func_get_args() );
203 return $this->
__call( __FUNCTION__, func_get_args() );
207 return $this->
__call( __FUNCTION__, func_get_args() );
211 return $this->
__call( __FUNCTION__, func_get_args() );
215 return $this->
__call( __FUNCTION__, func_get_args() );
219 return $this->
__call( __FUNCTION__, func_get_args() );
223 return $this->
__call( __FUNCTION__, func_get_args() );
227 return $this->
__call( __FUNCTION__, func_get_args() );
230 public function query( $sql,
$fname = __METHOD__, $tempIgnore =
false ) {
231 return $this->
__call( __FUNCTION__, func_get_args() );
235 return $this->
__call( __FUNCTION__, func_get_args() );
239 return $this->
__call( __FUNCTION__, func_get_args() );
245 return $this->
__call( __FUNCTION__, func_get_args() );
251 return $this->
__call( __FUNCTION__, func_get_args() );
258 return $this->
__call( __FUNCTION__, func_get_args() );
265 return $this->
__call( __FUNCTION__, func_get_args() );
272 return $this->
__call( __FUNCTION__, func_get_args() );
278 return $this->
__call( __FUNCTION__, func_get_args() );
284 return $this->
__call( __FUNCTION__, func_get_args() );
288 return $this->
__call( __FUNCTION__, func_get_args() );
292 return $this->
__call( __FUNCTION__, func_get_args() );
296 return $this->
__call( __FUNCTION__, func_get_args() );
300 return $this->
__call( __FUNCTION__, func_get_args() );
304 return $this->
__call( __FUNCTION__, func_get_args() );
308 return $this->
__call( __FUNCTION__, func_get_args() );
311 public function makeList( $a, $mode = self::LIST_COMMA ) {
312 return $this->
__call( __FUNCTION__, func_get_args() );
316 return $this->
__call( __FUNCTION__, func_get_args() );
320 return $this->
__call( __FUNCTION__, func_get_args() );
324 return $this->
__call( __FUNCTION__, func_get_args() );
327 public function bitAnd( $fieldLeft, $fieldRight ) {
328 return $this->
__call( __FUNCTION__, func_get_args() );
331 public function bitOr( $fieldLeft, $fieldRight ) {
332 return $this->
__call( __FUNCTION__, func_get_args() );
336 return $this->
__call( __FUNCTION__, func_get_args() );
340 $delim, $table, $field, $conds =
'', $join_conds = []
342 return $this->
__call( __FUNCTION__, func_get_args() );
346 return $this->
__call( __FUNCTION__, func_get_args() );
350 return $this->
__call( __FUNCTION__, func_get_args() );
354 return $this->
__call( __FUNCTION__, func_get_args() );
358 return $this->
__call( __FUNCTION__, func_get_args() );
362 return $this->
__call( __FUNCTION__, func_get_args() );
366 return $this->
__call( __FUNCTION__, func_get_args() );
370 return $this->
__call( __FUNCTION__, func_get_args() );
374 return $this->
__call( __FUNCTION__, func_get_args() );
378 return $this->
__call( __FUNCTION__, func_get_args() );
381 public function replace( $table, $uniqueIndexes, $rows,
$fname = __METHOD__ ) {
382 return $this->
__call( __FUNCTION__, func_get_args() );
388 return $this->
__call( __FUNCTION__, func_get_args() );
392 $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname = __METHOD__
394 return $this->
__call( __FUNCTION__, func_get_args() );
397 public function delete( $table, $conds,
$fname = __METHOD__ ) {
398 return $this->
__call( __FUNCTION__, func_get_args() );
402 $destTable, $srcTable, $varMap, $conds,
403 $fname = __METHOD__, $insertOptions = [], $selectOptions = []
405 return $this->
__call( __FUNCTION__, func_get_args() );
409 return $this->
__call( __FUNCTION__, func_get_args() );
413 return $this->
__call( __FUNCTION__, func_get_args() );
417 return $this->
__call( __FUNCTION__, func_get_args() );
421 return $this->
__call( __FUNCTION__, func_get_args() );
425 return $this->
__call( __FUNCTION__, func_get_args() );
429 return $this->
__call( __FUNCTION__, func_get_args() );
433 return $this->
__call( __FUNCTION__, func_get_args() );
437 return $this->
__call( __FUNCTION__, func_get_args() );
441 return $this->
__call( __FUNCTION__, func_get_args() );
445 return $this->
__call( __FUNCTION__, func_get_args() );
449 return $this->
__call( __FUNCTION__, func_get_args() );
453 return $this->
__call( __FUNCTION__, func_get_args() );
457 return $this->
__call( __FUNCTION__, func_get_args() );
461 return $this->
__call( __FUNCTION__, func_get_args() );
465 return $this->
__call( __FUNCTION__, func_get_args() );
469 return $this->
__call( __FUNCTION__, func_get_args() );
473 return $this->
__call( __FUNCTION__, func_get_args() );
477 return $this->
__call( __FUNCTION__, func_get_args() );
481 return $this->
__call( __FUNCTION__, func_get_args() );
485 return $this->
__call( __FUNCTION__, func_get_args() );
488 public function begin(
$fname = __METHOD__, $mode = IDatabase::TRANSACTION_EXPLICIT ) {
489 return $this->
__call( __FUNCTION__, func_get_args() );
493 return $this->
__call( __FUNCTION__, func_get_args() );
497 return $this->
__call( __FUNCTION__, func_get_args() );
501 return $this->
__call( __FUNCTION__, func_get_args() );
505 return $this->
__call( __FUNCTION__, func_get_args() );
509 return $this->
__call( __FUNCTION__, func_get_args() );
513 return $this->
__call( __FUNCTION__, func_get_args() );
516 public function ping( &$rtt =
null ) {
517 return func_num_args()
518 ? $this->
__call( __FUNCTION__, [ &$rtt ] )
519 : $this->
__call( __FUNCTION__, [] );
523 return $this->
__call( __FUNCTION__, func_get_args() );
527 return $this->
__call( __FUNCTION__, func_get_args() );
531 return $this->
__call( __FUNCTION__, func_get_args() );
535 return $this->
__call( __FUNCTION__, func_get_args() );
539 return $this->
__call( __FUNCTION__, func_get_args() );
543 return $this->
__call( __FUNCTION__, func_get_args() );
547 return $this->
__call( __FUNCTION__, func_get_args() );
551 return $this->
__call( __FUNCTION__, func_get_args() );
554 public function lock( $lockName, $method, $timeout = 5 ) {
555 return $this->
__call( __FUNCTION__, func_get_args() );
558 public function unlock( $lockName, $method ) {
559 return $this->
__call( __FUNCTION__, func_get_args() );
563 return $this->
__call( __FUNCTION__, func_get_args() );
567 return $this->
__call( __FUNCTION__, func_get_args() );
571 return $this->
__call( __FUNCTION__, func_get_args() );
575 return $this->
__call( __FUNCTION__, func_get_args() );
579 return $this->
__call( __FUNCTION__, func_get_args() );
583 return $this->
__call( __FUNCTION__, func_get_args() );
587 return $this->
__call( __FUNCTION__, func_get_args() );
591 return $this->
__call( __FUNCTION__, func_get_args() );
598 if ( $this->conn !==
null ) {
599 $this->lb->reuseConnection( $this->conn );
608 return $this->
__call( __FUNCTION__, func_get_args() );
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
setLazyMasterHandle(IDatabase $conn)
Set a lazy-connecting DB handle to the master DB (for replication status purposes)
numFields( $res)
Get the number of fields in a result object.
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
insertId()
Get the inserted value of an auto-increment row.
close()
Closes a database connection.
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
The equivalent of IDatabase::select() except that the constructed SQL is returned,...
lastDoneWrites()
Returns the last time the connection may have been used for write queries.
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
array null $params
N-tuple of (server index, group, DatabaseDomain|string)
unionQueries( $sqls, $all)
Construct a UNION query This is used for providing overload point for other DB abstractions not compa...
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[])
INSERT SELECT wrapper.
fetchObject( $res)
Fetch the next row from the given result object, in object form.
addQuotes( $s)
Adds quotes and backslashes.
strreplace( $orig, $old, $new)
Returns a comand for str_replace function in SQL query.
selectRowCount( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
getWikiID()
Alias for getDomainID()
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
indexUnique( $table, $index)
Determines if a given index is unique.
setTransactionListener( $name, callable $callback=null)
Run a callback each time any transaction commits or rolls back.
trxLevel()
Gets the current transaction level.
conditional( $cond, $trueVal, $falseVal)
Returns an SQL expression for a simple conditional.
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
buildLike()
LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match conta...
replace( $table, $uniqueIndexes, $rows, $fname=__METHOD__)
REPLACE query wrapper.
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
bitOr( $fieldLeft, $fieldRight)
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
getServer()
Get the server hostname or IP address.
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
dbSchema( $schema=null)
Get/set the db schema.
fieldName( $res, $n)
Get a field name in a result object.
lastErrno()
Get the last error number.
lastQuery()
Return the last query that went through IDatabase::query()
wasErrorReissuable()
Determines if the last query error was due to a dropped connection and should be dealt with by pingin...
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
wasDeadlock()
Determines if the last failure was due to a deadlock.
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
writesOrCallbacksPending()
Returns true if there is a transaction open with possible write queries or transaction pre-commit/idl...
flushSnapshot( $fname=__METHOD__)
Commit any transaction but error out if writes or callbacks are pending.
makeList( $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
__destruct()
Clean up the connection when out of scope.
upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname=__METHOD__)
INSERT ON DUPLICATE KEY UPDATE wrapper, upserts an array into a table.
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
tablePrefix( $prefix=null)
Get/set the table prefix.
getDBname()
Get the current DB name.
IDatabase null $conn
Live connection handle.
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
rollback( $fname=__METHOD__, $flush='')
Rollback a transaction previously started using begin().
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
bufferResults( $buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
freeResult( $res)
Free a result object returned by query() or select().
setLBInfo( $name, $value=null)
Set the LB info array, or a member of it.
setSessionOptions(array $options)
Override database's default behavior.
lastError()
Get a description of the last error.
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
affectedRows()
Get the number of rows affected by the last write query.
numRows( $res)
Get the number of rows in a result object.
doAtomicSection( $fname, callable $callback)
Run a callback to do an atomic set of updates for this database.
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a single field from a single result row.
estimateRowCount( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=[])
Estimate the number of rows in dataset.
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a list of single field values from result rows.
open( $server, $user, $password, $dbName)
Open a connection to the database.
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
bitAnd( $fieldLeft, $fieldRight)
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
unionSupportsOrderAndLimit()
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within th...
fieldInfo( $table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
getMasterPos()
Get the position of this master.
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists Usually throws a DBQueryError on failure If errors are explicitly ...
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[http://www.mysql.com/ MySQL]"; Should at ...
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
getLag()
Get replica DB lag.
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
isOpen()
Is a connection to the database open?
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
unlock( $lockName, $method)
Release a lock.
doneWrites()
Returns true if the connection may have been used for write queries.
nextSequenceValue( $seqName)
Returns an appropriately quoted sequence value for inserting a new row.
__construct(ILoadBalancer $lb, $conn)
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
getServerUptime()
Determines how long the server has been up.
begin( $fname=__METHOD__, $mode=IDatabase::TRANSACTION_EXPLICIT)
Begin a transaction.
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
lockIsFree( $lockName, $method)
Check to see if a named lock is available (non-blocking)
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
reportConnectionError( $error='Unknown error')
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
getServerInfo()
A string describing the current software version, and possibly other details in a user-friendly way.
reportQueryError( $error, $errno, $sql, $fname, $tempIgnore=false)
Report a query error.
commit( $fname=__METHOD__, $flush='')
Commits a transaction previously started using begin().
__call( $name, array $arguments)
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
selectDB( $db)
Change the current database.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
startAtomic( $fname=__METHOD__)
Begin an atomic section of statements.
dataSeek( $res, $row)
Change the position of the cursor in a result object.
getInfinity()
Find out when 'infinity' is.
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
getReplicaPos()
Get the replication position of this replica DB.
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Class to handle database/prefix specification for IDatabase domains.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
the array() calling protocol came about after MediaWiki 1.4rc1.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Allows to change the fields on the form that will be generated $name
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
An object representing a master or replica DB position in a replicated setup.
Basic database interface for live and lazy-loaded relation database handles.
Database cluster connection, tracking, load balancing, and transaction manager interface.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)