MediaWiki  1.29.2
DBConnRef.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
5 use InvalidArgumentException;
6 
15 class DBConnRef implements IDatabase {
17  private $lb;
19  private $conn;
21  private $params;
22 
23  const FLD_INDEX = 0;
24  const FLD_GROUP = 1;
25  const FLD_DOMAIN = 2;
26 
31  public function __construct( ILoadBalancer $lb, $conn ) {
32  $this->lb = $lb;
33  if ( $conn instanceof Database ) {
34  $this->conn = $conn; // live handle
35  } elseif ( count( $conn ) >= 3 && $conn[self::FLD_DOMAIN] !== false ) {
36  $this->params = $conn;
37  } else {
38  throw new InvalidArgumentException( "Missing lazy connection arguments." );
39  }
40  }
41 
42  function __call( $name, array $arguments ) {
43  if ( $this->conn === null ) {
44  list( $db, $groups, $wiki ) = $this->params;
45  $this->conn = $this->lb->getConnection( $db, $groups, $wiki );
46  }
47 
48  return call_user_func_array( [ $this->conn, $name ], $arguments );
49  }
50 
51  public function getServerInfo() {
52  return $this->__call( __FUNCTION__, func_get_args() );
53  }
54 
55  public function bufferResults( $buffer = null ) {
56  return $this->__call( __FUNCTION__, func_get_args() );
57  }
58 
59  public function trxLevel() {
60  return $this->__call( __FUNCTION__, func_get_args() );
61  }
62 
63  public function trxTimestamp() {
64  return $this->__call( __FUNCTION__, func_get_args() );
65  }
66 
67  public function explicitTrxActive() {
68  return $this->__call( __FUNCTION__, func_get_args() );
69  }
70 
71  public function tablePrefix( $prefix = null ) {
72  return $this->__call( __FUNCTION__, func_get_args() );
73  }
74 
75  public function dbSchema( $schema = null ) {
76  return $this->__call( __FUNCTION__, func_get_args() );
77  }
78 
79  public function getLBInfo( $name = null ) {
80  return $this->__call( __FUNCTION__, func_get_args() );
81  }
82 
83  public function setLBInfo( $name, $value = null ) {
84  return $this->__call( __FUNCTION__, func_get_args() );
85  }
86 
87  public function setLazyMasterHandle( IDatabase $conn ) {
88  return $this->__call( __FUNCTION__, func_get_args() );
89  }
90 
91  public function implicitGroupby() {
92  return $this->__call( __FUNCTION__, func_get_args() );
93  }
94 
95  public function implicitOrderby() {
96  return $this->__call( __FUNCTION__, func_get_args() );
97  }
98 
99  public function lastQuery() {
100  return $this->__call( __FUNCTION__, func_get_args() );
101  }
102 
103  public function doneWrites() {
104  return $this->__call( __FUNCTION__, func_get_args() );
105  }
106 
107  public function lastDoneWrites() {
108  return $this->__call( __FUNCTION__, func_get_args() );
109  }
110 
111  public function writesPending() {
112  return $this->__call( __FUNCTION__, func_get_args() );
113  }
114 
115  public function writesOrCallbacksPending() {
116  return $this->__call( __FUNCTION__, func_get_args() );
117  }
118 
119  public function pendingWriteQueryDuration( $type = self::ESTIMATE_TOTAL ) {
120  return $this->__call( __FUNCTION__, func_get_args() );
121  }
122 
123  public function pendingWriteCallers() {
124  return $this->__call( __FUNCTION__, func_get_args() );
125  }
126 
127  public function isOpen() {
128  return $this->__call( __FUNCTION__, func_get_args() );
129  }
130 
131  public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
132  return $this->__call( __FUNCTION__, func_get_args() );
133  }
134 
135  public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
136  return $this->__call( __FUNCTION__, func_get_args() );
137  }
138 
139  public function restoreFlags( $state = self::RESTORE_PRIOR ) {
140  return $this->__call( __FUNCTION__, func_get_args() );
141  }
142 
143  public function getFlag( $flag ) {
144  return $this->__call( __FUNCTION__, func_get_args() );
145  }
146 
147  public function getProperty( $name ) {
148  return $this->__call( __FUNCTION__, func_get_args() );
149  }
150 
151  public function getDomainID() {
152  if ( $this->conn === null ) {
153  $domain = $this->params[self::FLD_DOMAIN];
154  // Avoid triggering a database connection
155  return $domain instanceof DatabaseDomain ? $domain->getId() : $domain;
156  }
157 
158  return $this->__call( __FUNCTION__, func_get_args() );
159  }
160 
161  public function getWikiID() {
162  return $this->getDomainID();
163  }
164 
165  public function getType() {
166  return $this->__call( __FUNCTION__, func_get_args() );
167  }
168 
169  public function open( $server, $user, $password, $dbName ) {
170  return $this->__call( __FUNCTION__, func_get_args() );
171  }
172 
173  public function fetchObject( $res ) {
174  return $this->__call( __FUNCTION__, func_get_args() );
175  }
176 
177  public function fetchRow( $res ) {
178  return $this->__call( __FUNCTION__, func_get_args() );
179  }
180 
181  public function numRows( $res ) {
182  return $this->__call( __FUNCTION__, func_get_args() );
183  }
184 
185  public function numFields( $res ) {
186  return $this->__call( __FUNCTION__, func_get_args() );
187  }
188 
189  public function fieldName( $res, $n ) {
190  return $this->__call( __FUNCTION__, func_get_args() );
191  }
192 
193  public function insertId() {
194  return $this->__call( __FUNCTION__, func_get_args() );
195  }
196 
197  public function dataSeek( $res, $row ) {
198  return $this->__call( __FUNCTION__, func_get_args() );
199  }
200 
201  public function lastErrno() {
202  return $this->__call( __FUNCTION__, func_get_args() );
203  }
204 
205  public function lastError() {
206  return $this->__call( __FUNCTION__, func_get_args() );
207  }
208 
209  public function fieldInfo( $table, $field ) {
210  return $this->__call( __FUNCTION__, func_get_args() );
211  }
212 
213  public function affectedRows() {
214  return $this->__call( __FUNCTION__, func_get_args() );
215  }
216 
217  public function getSoftwareLink() {
218  return $this->__call( __FUNCTION__, func_get_args() );
219  }
220 
221  public function getServerVersion() {
222  return $this->__call( __FUNCTION__, func_get_args() );
223  }
224 
225  public function close() {
226  return $this->__call( __FUNCTION__, func_get_args() );
227  }
228 
229  public function reportConnectionError( $error = 'Unknown error' ) {
230  return $this->__call( __FUNCTION__, func_get_args() );
231  }
232 
233  public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) {
234  return $this->__call( __FUNCTION__, func_get_args() );
235  }
236 
237  public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
238  return $this->__call( __FUNCTION__, func_get_args() );
239  }
240 
241  public function freeResult( $res ) {
242  return $this->__call( __FUNCTION__, func_get_args() );
243  }
244 
245  public function selectField(
246  $table, $var, $cond = '', $fname = __METHOD__, $options = []
247  ) {
248  return $this->__call( __FUNCTION__, func_get_args() );
249  }
250 
251  public function selectFieldValues(
252  $table, $var, $cond = '', $fname = __METHOD__, $options = []
253  ) {
254  return $this->__call( __FUNCTION__, func_get_args() );
255  }
256 
257  public function select(
258  $table, $vars, $conds = '', $fname = __METHOD__,
259  $options = [], $join_conds = []
260  ) {
261  return $this->__call( __FUNCTION__, func_get_args() );
262  }
263 
264  public function selectSQLText(
265  $table, $vars, $conds = '', $fname = __METHOD__,
266  $options = [], $join_conds = []
267  ) {
268  return $this->__call( __FUNCTION__, func_get_args() );
269  }
270 
271  public function selectRow(
272  $table, $vars, $conds, $fname = __METHOD__,
273  $options = [], $join_conds = []
274  ) {
275  return $this->__call( __FUNCTION__, func_get_args() );
276  }
277 
278  public function estimateRowCount(
279  $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = []
280  ) {
281  return $this->__call( __FUNCTION__, func_get_args() );
282  }
283 
284  public function selectRowCount(
285  $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
286  ) {
287  return $this->__call( __FUNCTION__, func_get_args() );
288  }
289 
290  public function fieldExists( $table, $field, $fname = __METHOD__ ) {
291  return $this->__call( __FUNCTION__, func_get_args() );
292  }
293 
294  public function indexExists( $table, $index, $fname = __METHOD__ ) {
295  return $this->__call( __FUNCTION__, func_get_args() );
296  }
297 
298  public function tableExists( $table, $fname = __METHOD__ ) {
299  return $this->__call( __FUNCTION__, func_get_args() );
300  }
301 
302  public function indexUnique( $table, $index ) {
303  return $this->__call( __FUNCTION__, func_get_args() );
304  }
305 
306  public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
307  return $this->__call( __FUNCTION__, func_get_args() );
308  }
309 
310  public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {
311  return $this->__call( __FUNCTION__, func_get_args() );
312  }
313 
314  public function makeList( $a, $mode = self::LIST_COMMA ) {
315  return $this->__call( __FUNCTION__, func_get_args() );
316  }
317 
318  public function makeWhereFrom2d( $data, $baseKey, $subKey ) {
319  return $this->__call( __FUNCTION__, func_get_args() );
320  }
321 
322  public function aggregateValue( $valuedata, $valuename = 'value' ) {
323  return $this->__call( __FUNCTION__, func_get_args() );
324  }
325 
326  public function bitNot( $field ) {
327  return $this->__call( __FUNCTION__, func_get_args() );
328  }
329 
330  public function bitAnd( $fieldLeft, $fieldRight ) {
331  return $this->__call( __FUNCTION__, func_get_args() );
332  }
333 
334  public function bitOr( $fieldLeft, $fieldRight ) {
335  return $this->__call( __FUNCTION__, func_get_args() );
336  }
337 
338  public function buildConcat( $stringList ) {
339  return $this->__call( __FUNCTION__, func_get_args() );
340  }
341 
342  public function buildGroupConcatField(
343  $delim, $table, $field, $conds = '', $join_conds = []
344  ) {
345  return $this->__call( __FUNCTION__, func_get_args() );
346  }
347 
348  public function buildStringCast( $field ) {
349  return $this->__call( __FUNCTION__, func_get_args() );
350  }
351 
352  public function selectDB( $db ) {
353  return $this->__call( __FUNCTION__, func_get_args() );
354  }
355 
356  public function getDBname() {
357  return $this->__call( __FUNCTION__, func_get_args() );
358  }
359 
360  public function getServer() {
361  return $this->__call( __FUNCTION__, func_get_args() );
362  }
363 
364  public function addQuotes( $s ) {
365  return $this->__call( __FUNCTION__, func_get_args() );
366  }
367 
368  public function buildLike() {
369  return $this->__call( __FUNCTION__, func_get_args() );
370  }
371 
372  public function anyChar() {
373  return $this->__call( __FUNCTION__, func_get_args() );
374  }
375 
376  public function anyString() {
377  return $this->__call( __FUNCTION__, func_get_args() );
378  }
379 
380  public function nextSequenceValue( $seqName ) {
381  return $this->__call( __FUNCTION__, func_get_args() );
382  }
383 
384  public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) {
385  return $this->__call( __FUNCTION__, func_get_args() );
386  }
387 
388  public function upsert(
389  $table, array $rows, array $uniqueIndexes, array $set, $fname = __METHOD__
390  ) {
391  return $this->__call( __FUNCTION__, func_get_args() );
392  }
393 
394  public function deleteJoin(
395  $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = __METHOD__
396  ) {
397  return $this->__call( __FUNCTION__, func_get_args() );
398  }
399 
400  public function delete( $table, $conds, $fname = __METHOD__ ) {
401  return $this->__call( __FUNCTION__, func_get_args() );
402  }
403 
404  public function insertSelect(
405  $destTable, $srcTable, $varMap, $conds,
406  $fname = __METHOD__, $insertOptions = [], $selectOptions = []
407  ) {
408  return $this->__call( __FUNCTION__, func_get_args() );
409  }
410 
411  public function unionSupportsOrderAndLimit() {
412  return $this->__call( __FUNCTION__, func_get_args() );
413  }
414 
415  public function unionQueries( $sqls, $all ) {
416  return $this->__call( __FUNCTION__, func_get_args() );
417  }
418 
419  public function conditional( $cond, $trueVal, $falseVal ) {
420  return $this->__call( __FUNCTION__, func_get_args() );
421  }
422 
423  public function strreplace( $orig, $old, $new ) {
424  return $this->__call( __FUNCTION__, func_get_args() );
425  }
426 
427  public function getServerUptime() {
428  return $this->__call( __FUNCTION__, func_get_args() );
429  }
430 
431  public function wasDeadlock() {
432  return $this->__call( __FUNCTION__, func_get_args() );
433  }
434 
435  public function wasLockTimeout() {
436  return $this->__call( __FUNCTION__, func_get_args() );
437  }
438 
439  public function wasErrorReissuable() {
440  return $this->__call( __FUNCTION__, func_get_args() );
441  }
442 
443  public function wasReadOnlyError() {
444  return $this->__call( __FUNCTION__, func_get_args() );
445  }
446 
447  public function masterPosWait( DBMasterPos $pos, $timeout ) {
448  return $this->__call( __FUNCTION__, func_get_args() );
449  }
450 
451  public function getReplicaPos() {
452  return $this->__call( __FUNCTION__, func_get_args() );
453  }
454 
455  public function getMasterPos() {
456  return $this->__call( __FUNCTION__, func_get_args() );
457  }
458 
459  public function serverIsReadOnly() {
460  return $this->__call( __FUNCTION__, func_get_args() );
461  }
462 
463  public function onTransactionResolution( callable $callback, $fname = __METHOD__ ) {
464  return $this->__call( __FUNCTION__, func_get_args() );
465  }
466 
467  public function onTransactionIdle( callable $callback, $fname = __METHOD__ ) {
468  return $this->__call( __FUNCTION__, func_get_args() );
469  }
470 
471  public function onTransactionPreCommitOrIdle( callable $callback, $fname = __METHOD__ ) {
472  return $this->__call( __FUNCTION__, func_get_args() );
473  }
474 
475  public function setTransactionListener( $name, callable $callback = null ) {
476  return $this->__call( __FUNCTION__, func_get_args() );
477  }
478 
479  public function startAtomic( $fname = __METHOD__ ) {
480  return $this->__call( __FUNCTION__, func_get_args() );
481  }
482 
483  public function endAtomic( $fname = __METHOD__ ) {
484  return $this->__call( __FUNCTION__, func_get_args() );
485  }
486 
487  public function doAtomicSection( $fname, callable $callback ) {
488  return $this->__call( __FUNCTION__, func_get_args() );
489  }
490 
491  public function begin( $fname = __METHOD__, $mode = IDatabase::TRANSACTION_EXPLICIT ) {
492  return $this->__call( __FUNCTION__, func_get_args() );
493  }
494 
495  public function commit( $fname = __METHOD__, $flush = '' ) {
496  return $this->__call( __FUNCTION__, func_get_args() );
497  }
498 
499  public function rollback( $fname = __METHOD__, $flush = '' ) {
500  return $this->__call( __FUNCTION__, func_get_args() );
501  }
502 
503  public function flushSnapshot( $fname = __METHOD__ ) {
504  return $this->__call( __FUNCTION__, func_get_args() );
505  }
506 
507  public function listTables( $prefix = null, $fname = __METHOD__ ) {
508  return $this->__call( __FUNCTION__, func_get_args() );
509  }
510 
511  public function timestamp( $ts = 0 ) {
512  return $this->__call( __FUNCTION__, func_get_args() );
513  }
514 
515  public function timestampOrNull( $ts = null ) {
516  return $this->__call( __FUNCTION__, func_get_args() );
517  }
518 
519  public function ping( &$rtt = null ) {
520  return func_num_args()
521  ? $this->__call( __FUNCTION__, [ &$rtt ] )
522  : $this->__call( __FUNCTION__, [] ); // method cares about null vs missing
523  }
524 
525  public function getLag() {
526  return $this->__call( __FUNCTION__, func_get_args() );
527  }
528 
529  public function getSessionLagStatus() {
530  return $this->__call( __FUNCTION__, func_get_args() );
531  }
532 
533  public function maxListLen() {
534  return $this->__call( __FUNCTION__, func_get_args() );
535  }
536 
537  public function encodeBlob( $b ) {
538  return $this->__call( __FUNCTION__, func_get_args() );
539  }
540 
541  public function decodeBlob( $b ) {
542  return $this->__call( __FUNCTION__, func_get_args() );
543  }
544 
545  public function setSessionOptions( array $options ) {
546  return $this->__call( __FUNCTION__, func_get_args() );
547  }
548 
549  public function setSchemaVars( $vars ) {
550  return $this->__call( __FUNCTION__, func_get_args() );
551  }
552 
553  public function lockIsFree( $lockName, $method ) {
554  return $this->__call( __FUNCTION__, func_get_args() );
555  }
556 
557  public function lock( $lockName, $method, $timeout = 5 ) {
558  return $this->__call( __FUNCTION__, func_get_args() );
559  }
560 
561  public function unlock( $lockName, $method ) {
562  return $this->__call( __FUNCTION__, func_get_args() );
563  }
564 
565  public function getScopedLockAndFlush( $lockKey, $fname, $timeout ) {
566  return $this->__call( __FUNCTION__, func_get_args() );
567  }
568 
569  public function namedLocksEnqueue() {
570  return $this->__call( __FUNCTION__, func_get_args() );
571  }
572 
573  public function getInfinity() {
574  return $this->__call( __FUNCTION__, func_get_args() );
575  }
576 
577  public function encodeExpiry( $expiry ) {
578  return $this->__call( __FUNCTION__, func_get_args() );
579  }
580 
581  public function decodeExpiry( $expiry, $format = TS_MW ) {
582  return $this->__call( __FUNCTION__, func_get_args() );
583  }
584 
585  public function setBigSelects( $value = true ) {
586  return $this->__call( __FUNCTION__, func_get_args() );
587  }
588 
589  public function isReadOnly() {
590  return $this->__call( __FUNCTION__, func_get_args() );
591  }
592 
593  public function setTableAliases( array $aliases ) {
594  return $this->__call( __FUNCTION__, func_get_args() );
595  }
596 
600  function __destruct() {
601  if ( $this->conn ) {
602  $this->lb->reuseConnection( $this->conn );
603  }
604  }
605 }
606 
607 class_alias( DBConnRef::class, 'DBConnRef' );
Wikimedia\Rdbms\DBConnRef\isOpen
isOpen()
Is a connection to the database open?
Definition: DBConnRef.php:127
Wikimedia\Rdbms\DBConnRef\doAtomicSection
doAtomicSection( $fname, callable $callback)
Run a callback to do an atomic set of updates for this database.
Definition: DBConnRef.php:487
Wikimedia\Rdbms\DBConnRef\explicitTrxActive
explicitTrxActive()
Definition: DBConnRef.php:67
Wikimedia\Rdbms\DBConnRef\affectedRows
affectedRows()
Get the number of rows affected by the last write query.
Definition: DBConnRef.php:213
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:45
Wikimedia\Rdbms\DBConnRef\strreplace
strreplace( $orig, $old, $new)
Returns a comand for str_replace function in SQL query.
Definition: DBConnRef.php:423
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:990
Wikimedia\Rdbms\DBConnRef\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
Definition: DBConnRef.php:165
Wikimedia\Rdbms\DatabaseDomain\getId
getId()
Definition: DatabaseDomain.php:137
Wikimedia\Rdbms\DBConnRef\buildGroupConcatField
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=[])
Build a GROUP_CONCAT or equivalent statement for a query.
Definition: DBConnRef.php:342
Wikimedia\Rdbms\DBConnRef\listTables
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
Definition: DBConnRef.php:507
Wikimedia\Rdbms\DBConnRef\nextSequenceValue
nextSequenceValue( $seqName)
Returns an appropriately quoted sequence value for inserting a new row.
Definition: DBConnRef.php:380
Wikimedia\Rdbms\DBConnRef\decodeExpiry
decodeExpiry( $expiry, $format=TS_MW)
Decode an expiry time into a DBMS independent format.
Definition: DBConnRef.php:581
captcha-old.count
count
Definition: captcha-old.py:225
Wikimedia\Rdbms\DBConnRef\buildLike
buildLike()
LIKE statement wrapper, receives a variable-length argument list with parts of pattern to match conta...
Definition: DBConnRef.php:368
Wikimedia\Rdbms\DBConnRef\setSessionOptions
setSessionOptions(array $options)
Override database's default behavior.
Definition: DBConnRef.php:545
Wikimedia\Rdbms\DBConnRef\reportConnectionError
reportConnectionError( $error='Unknown error')
Definition: DBConnRef.php:229
Wikimedia\Rdbms\DBConnRef\makeList
makeList( $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
Definition: DBConnRef.php:314
Wikimedia\Rdbms\DBConnRef\serverIsReadOnly
serverIsReadOnly()
Definition: DBConnRef.php:459
Wikimedia\Rdbms\DBConnRef\tableExists
tableExists( $table, $fname=__METHOD__)
Query whether a given table exists.
Definition: DBConnRef.php:298
Wikimedia\Rdbms\DBConnRef\fieldInfo
fieldInfo( $table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
Definition: DBConnRef.php:209
Wikimedia\Rdbms\DBConnRef\anyString
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
Definition: DBConnRef.php:376
Wikimedia\Rdbms\DBConnRef\selectRowCount
selectRowCount( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Get the number of rows in dataset.
Definition: DBConnRef.php:284
use
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
Definition: MIT-LICENSE.txt:10
Wikimedia\Rdbms\DBConnRef\conditional
conditional( $cond, $trueVal, $falseVal)
Returns an SQL expression for a simple conditional.
Definition: DBConnRef.php:419
$user
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
Definition: hooks.txt:246
Wikimedia\Rdbms\DBConnRef\timestampOrNull
timestampOrNull( $ts=null)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
Definition: DBConnRef.php:515
Wikimedia\Rdbms\DBConnRef\dataSeek
dataSeek( $res, $row)
Change the position of the cursor in a result object.
Definition: DBConnRef.php:197
Wikimedia\Rdbms\DBConnRef\getDomainID
getDomainID()
Definition: DBConnRef.php:151
Wikimedia\Rdbms\DBConnRef\$lb
ILoadBalancer $lb
Definition: DBConnRef.php:17
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
Wikimedia\Rdbms\DBConnRef\$params
array null $params
N-tuple of (server index, group, DatabaseDomain|string)
Definition: DBConnRef.php:21
Wikimedia\Rdbms\DBConnRef\unionSupportsOrderAndLimit
unionSupportsOrderAndLimit()
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within th...
Definition: DBConnRef.php:411
Wikimedia\Rdbms\DBMasterPos
An object representing a master or replica DB position in a replicated setup.
Definition: DBMasterPos.php:10
Wikimedia\Rdbms\DBConnRef\buildStringCast
buildStringCast( $field)
Definition: DBConnRef.php:348
Wikimedia\Rdbms\DBConnRef\getLag
getLag()
Get replica DB lag.
Definition: DBConnRef.php:525
Wikimedia\Rdbms\DBConnRef\bufferResults
bufferResults( $buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
Definition: DBConnRef.php:55
Wikimedia\Rdbms\DBConnRef\pendingWriteCallers
pendingWriteCallers()
Get the list of method names that did write queries for this transaction.
Definition: DBConnRef.php:123
$s
$s
Definition: mergeMessageFileList.php:188
Wikimedia\Rdbms\DBConnRef\setFlag
setFlag( $flag, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
Definition: DBConnRef.php:131
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
Wikimedia\Rdbms\DBConnRef\maxListLen
maxListLen()
Return the maximum number of items allowed in a list, or 0 for unlimited.
Definition: DBConnRef.php:533
Wikimedia\Rdbms\DBConnRef\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
Definition: DBConnRef.php:306
Wikimedia\Rdbms\DBConnRef\getSessionLagStatus
getSessionLagStatus()
Get the replica DB lag when the current transaction started or a general lag estimate if not transact...
Definition: DBConnRef.php:529
Wikimedia\Rdbms\DBConnRef\implicitOrderby
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
Definition: DBConnRef.php:95
$type
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 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
Definition: hooks.txt:2536
Wikimedia\Rdbms\DBConnRef\lastError
lastError()
Get a description of the last error.
Definition: DBConnRef.php:205
Wikimedia\Rdbms\DBConnRef\getFlag
getFlag( $flag)
Returns a boolean whether the flag $flag is set for this connection.
Definition: DBConnRef.php:143
Wikimedia\Rdbms\DBConnRef\wasLockTimeout
wasLockTimeout()
Determines if the last failure was due to a lock timeout.
Definition: DBConnRef.php:435
Wikimedia\Rdbms\DBConnRef\rollback
rollback( $fname=__METHOD__, $flush='')
Rollback a transaction previously started using begin().
Definition: DBConnRef.php:499
Wikimedia\Rdbms\DBConnRef\selectField
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a single field from a single result row.
Definition: DBConnRef.php:245
php
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
Definition: injection.txt:35
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:40
Wikimedia\Rdbms\DBConnRef\getLBInfo
getLBInfo( $name=null)
Get properties passed down from the server info array of the load balancer.
Definition: DBConnRef.php:79
Wikimedia\Rdbms\DBConnRef\replace
replace( $table, $uniqueIndexes, $rows, $fname=__METHOD__)
REPLACE query wrapper.
Definition: DBConnRef.php:384
Wikimedia\Rdbms\DBConnRef\setTableAliases
setTableAliases(array $aliases)
Make certain table names use their own database, schema, and table prefix when passed into SQL querie...
Definition: DBConnRef.php:593
Wikimedia\Rdbms\DBConnRef\insertSelect
insertSelect( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[])
INSERT SELECT wrapper.
Definition: DBConnRef.php:404
Wikimedia\Rdbms\DBConnRef\getProperty
getProperty( $name)
Definition: DBConnRef.php:147
Wikimedia\Rdbms\DBConnRef\implicitGroupby
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
Definition: DBConnRef.php:91
Wikimedia\Rdbms\DBConnRef\getInfinity
getInfinity()
Find out when 'infinity' is.
Definition: DBConnRef.php:573
Wikimedia\Rdbms\DBConnRef\pendingWriteQueryDuration
pendingWriteQueryDuration( $type=self::ESTIMATE_TOTAL)
Get the time spend running write queries for this transaction.
Definition: DBConnRef.php:119
Wikimedia\Rdbms\DBConnRef\select
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
Definition: DBConnRef.php:257
Wikimedia\Rdbms\DBConnRef\$conn
Database null $conn
Live connection handle.
Definition: DBConnRef.php:19
Wikimedia\Rdbms\DBConnRef\upsert
upsert( $table, array $rows, array $uniqueIndexes, array $set, $fname=__METHOD__)
INSERT ON DUPLICATE KEY UPDATE wrapper, upserts an array into a table.
Definition: DBConnRef.php:388
Wikimedia\Rdbms\DBConnRef\selectRow
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
Definition: DBConnRef.php:271
Wikimedia\Rdbms\DBConnRef\getScopedLockAndFlush
getScopedLockAndFlush( $lockKey, $fname, $timeout)
Acquire a named lock, flush any transaction, and return an RAII style unlocker object.
Definition: DBConnRef.php:565
Wikimedia\Rdbms\DBConnRef\getServerInfo
getServerInfo()
A string describing the current software version, and possibly other details in a user-friendly way.
Definition: DBConnRef.php:51
Wikimedia\Rdbms\DBConnRef\indexExists
indexExists( $table, $index, $fname=__METHOD__)
Determines whether an index exists Usually throws a DBQueryError on failure If errors are explicitly ...
Definition: DBConnRef.php:294
Wikimedia\Rdbms\DBConnRef\encodeExpiry
encodeExpiry( $expiry)
Encode an expiry time into the DBMS dependent format.
Definition: DBConnRef.php:577
Wikimedia\Rdbms\DBConnRef\wasDeadlock
wasDeadlock()
Determines if the last failure was due to a deadlock.
Definition: DBConnRef.php:431
Wikimedia\Rdbms\DBConnRef\selectSQLText
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
The equivalent of IDatabase::select() except that the constructed SQL is returned,...
Definition: DBConnRef.php:264
Wikimedia\Rdbms\DBConnRef\writesOrCallbacksPending
writesOrCallbacksPending()
Returns true if there is a transaction open with possible write queries or transaction pre-commit/idl...
Definition: DBConnRef.php:115
Wikimedia\Rdbms\DBConnRef\__destruct
__destruct()
Clean up the connection when out of scope.
Definition: DBConnRef.php:600
Wikimedia\Rdbms\DBConnRef\fetchObject
fetchObject( $res)
Fetch the next row from the given result object, in object form.
Definition: DBConnRef.php:173
Wikimedia\Rdbms\DBConnRef\anyChar
anyChar()
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query.
Definition: DBConnRef.php:372
Wikimedia\Rdbms\DBConnRef\endAtomic
endAtomic( $fname=__METHOD__)
Ends an atomic section of SQL statements.
Definition: DBConnRef.php:483
Wikimedia\Rdbms\DBConnRef\unlock
unlock( $lockName, $method)
Release a lock.
Definition: DBConnRef.php:561
Wikimedia\Rdbms\DBConnRef\setSchemaVars
setSchemaVars( $vars)
Set variables to be used in sourceFile/sourceStream, in preference to the ones in $GLOBALS.
Definition: DBConnRef.php:549
Wikimedia\Rdbms\DBConnRef\tablePrefix
tablePrefix( $prefix=null)
Get/set the table prefix.
Definition: DBConnRef.php:71
Wikimedia\Rdbms\DBConnRef\writesPending
writesPending()
Definition: DBConnRef.php:111
Wikimedia\Rdbms\DBConnRef\getServer
getServer()
Get the server hostname or IP address.
Definition: DBConnRef.php:360
Wikimedia\Rdbms\DBConnRef\lock
lock( $lockName, $method, $timeout=5)
Acquire a named lock.
Definition: DBConnRef.php:557
$vars
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Definition: hooks.txt:2179
Wikimedia\Rdbms\DBConnRef\getWikiID
getWikiID()
Alias for getDomainID()
Definition: DBConnRef.php:161
Wikimedia\Rdbms\DBConnRef\fieldExists
fieldExists( $table, $field, $fname=__METHOD__)
Determines whether a field exists in a table.
Definition: DBConnRef.php:290
list
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
Definition: deferred.txt:11
Wikimedia\Rdbms\DBConnRef\selectDB
selectDB( $db)
Change the current database.
Definition: DBConnRef.php:352
Wikimedia\Rdbms\DBConnRef\setLazyMasterHandle
setLazyMasterHandle(IDatabase $conn)
Set a lazy-connecting DB handle to the master DB (for replication status purposes)
Definition: DBConnRef.php:87
Wikimedia\Rdbms\DBConnRef\fieldName
fieldName( $res, $n)
Get a field name in a result object.
Definition: DBConnRef.php:189
Wikimedia\Rdbms\DBConnRef\bitNot
bitNot( $field)
Definition: DBConnRef.php:326
LIST_COMMA
const LIST_COMMA
Definition: Defines.php:40
Wikimedia\Rdbms\DBConnRef\restoreFlags
restoreFlags( $state=self::RESTORE_PRIOR)
Restore the flags to their prior state before the last setFlag/clearFlag call.
Definition: DBConnRef.php:139
Wikimedia\Rdbms\DBConnRef\startAtomic
startAtomic( $fname=__METHOD__)
Begin an atomic section of statements.
Definition: DBConnRef.php:479
Wikimedia\Rdbms\DBConnRef\lastQuery
lastQuery()
Return the last query that went through IDatabase::query()
Definition: DBConnRef.php:99
Wikimedia\Rdbms\DBConnRef\getServerUptime
getServerUptime()
Determines how long the server has been up.
Definition: DBConnRef.php:427
Wikimedia\Rdbms\DBConnRef\getDBname
getDBname()
Get the current DB name.
Definition: DBConnRef.php:356
Wikimedia\Rdbms\DBConnRef\decodeBlob
decodeBlob( $b)
Some DBMSs return a special placeholder object representing blob fields in result objects.
Definition: DBConnRef.php:541
Wikimedia\Rdbms\DBConnRef\reportQueryError
reportQueryError( $error, $errno, $sql, $fname, $tempIgnore=false)
Report a query error.
Definition: DBConnRef.php:237
Wikimedia\Rdbms\DBConnRef\lastDoneWrites
lastDoneWrites()
Returns the last time the connection may have been used for write queries.
Definition: DBConnRef.php:107
Wikimedia\Rdbms\DBConnRef\FLD_GROUP
const FLD_GROUP
Definition: DBConnRef.php:24
$value
$value
Definition: styleTest.css.php:45
Wikimedia\Rdbms\DBConnRef\trxTimestamp
trxTimestamp()
Get the UNIX timestamp of the time that the transaction was established.
Definition: DBConnRef.php:63
Wikimedia\Rdbms\DBConnRef\trxLevel
trxLevel()
Gets the current transaction level.
Definition: DBConnRef.php:59
Wikimedia\Rdbms\DBConnRef\getSoftwareLink
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[https://www.mysql.com/ MySQL]"; Should at...
Definition: DBConnRef.php:217
Wikimedia\Rdbms\DBConnRef\FLD_INDEX
const FLD_INDEX
Definition: DBConnRef.php:23
Wikimedia\Rdbms\DBConnRef\addQuotes
addQuotes( $s)
Adds quotes and backslashes.
Definition: DBConnRef.php:364
Wikimedia\Rdbms\DBConnRef\timestamp
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
Definition: DBConnRef.php:511
Wikimedia\Rdbms\DBConnRef\wasReadOnlyError
wasReadOnlyError()
Determines if the last failure was due to the database being read-only.
Definition: DBConnRef.php:443
Wikimedia\Rdbms\DBConnRef\encodeBlob
encodeBlob( $b)
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strin...
Definition: DBConnRef.php:537
Wikimedia\Rdbms\DBConnRef\onTransactionResolution
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
Definition: DBConnRef.php:463
Wikimedia\Rdbms\DBConnRef\freeResult
freeResult( $res)
Free a result object returned by query() or select().
Definition: DBConnRef.php:241
Wikimedia\Rdbms\DBConnRef\buildConcat
buildConcat( $stringList)
Build a concatenation list to feed into a SQL query.
Definition: DBConnRef.php:338
Wikimedia\Rdbms\DBConnRef\makeWhereFrom2d
makeWhereFrom2d( $data, $baseKey, $subKey)
Build a partial where clause from a 2-d array such as used for LinkBatch.
Definition: DBConnRef.php:318
Wikimedia\Rdbms\DBConnRef\close
close()
Closes a database connection.
Definition: DBConnRef.php:225
Wikimedia\Rdbms\DBConnRef\setTransactionListener
setTransactionListener( $name, callable $callback=null)
Run a callback each time any transaction commits or rolls back.
Definition: DBConnRef.php:475
Wikimedia\Rdbms\DBConnRef\bitOr
bitOr( $fieldLeft, $fieldRight)
Definition: DBConnRef.php:334
Wikimedia\Rdbms\DBConnRef\setBigSelects
setBigSelects( $value=true)
Allow or deny "big selects" for this session only.
Definition: DBConnRef.php:585
Wikimedia\Rdbms\DBConnRef\numRows
numRows( $res)
Get the number of rows in a result object.
Definition: DBConnRef.php:181
Wikimedia\Rdbms\DBConnRef\update
update( $table, $values, $conds, $fname=__METHOD__, $options=[])
UPDATE wrapper.
Definition: DBConnRef.php:310
Wikimedia\Rdbms\DBConnRef\dbSchema
dbSchema( $schema=null)
Get/set the db schema.
Definition: DBConnRef.php:75
Wikimedia\Rdbms\DBConnRef
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handl...
Definition: DBConnRef.php:15
Wikimedia\Rdbms\DBConnRef\getReplicaPos
getReplicaPos()
Get the replication position of this replica DB.
Definition: DBConnRef.php:451
Wikimedia\Rdbms\DBConnRef\selectFieldValues
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a list of single field values from result rows.
Definition: DBConnRef.php:251
Wikimedia\Rdbms\DBConnRef\query
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
Definition: DBConnRef.php:233
Wikimedia\Rdbms\DBConnRef\ping
ping(&$rtt=null)
Ping the server and try to reconnect if it there is no connection.
Definition: DBConnRef.php:519
Wikimedia\Rdbms\DBConnRef\masterPosWait
masterPosWait(DBMasterPos $pos, $timeout)
Wait for the replica DB to catch up to a given master position.
Definition: DBConnRef.php:447
Wikimedia\Rdbms\DBConnRef\open
open( $server, $user, $password, $dbName)
Open a connection to the database.
Definition: DBConnRef.php:169
Wikimedia\Rdbms\DBConnRef\deleteJoin
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Definition: DBConnRef.php:394
Wikimedia\Rdbms\DBConnRef\unionQueries
unionQueries( $sqls, $all)
Construct a UNION query This is used for providing overload point for other DB abstractions not compa...
Definition: DBConnRef.php:415
Wikimedia\Rdbms\DBConnRef\setLBInfo
setLBInfo( $name, $value=null)
Set the LB info array, or a member of it.
Definition: DBConnRef.php:83
Wikimedia\Rdbms\DBConnRef\onTransactionPreCommitOrIdle
onTransactionPreCommitOrIdle(callable $callback, $fname=__METHOD__)
Run a callback before the current transaction commits or now if there is none.
Definition: DBConnRef.php:471
Wikimedia\Rdbms\DBConnRef\insertId
insertId()
Get the inserted value of an auto-increment row.
Definition: DBConnRef.php:193
Wikimedia\Rdbms\DBConnRef\doneWrites
doneWrites()
Returns true if the connection may have been used for write queries.
Definition: DBConnRef.php:103
Wikimedia\Rdbms\DBConnRef\isReadOnly
isReadOnly()
Definition: DBConnRef.php:589
Wikimedia\Rdbms\DBConnRef\getMasterPos
getMasterPos()
Get the position of this master.
Definition: DBConnRef.php:455
Wikimedia\Rdbms\DBConnRef\FLD_DOMAIN
const FLD_DOMAIN
Definition: DBConnRef.php:25
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Wikimedia\Rdbms\DBConnRef\numFields
numFields( $res)
Get the number of fields in a result object.
Definition: DBConnRef.php:185
Wikimedia\Rdbms\DBConnRef\flushSnapshot
flushSnapshot( $fname=__METHOD__)
Commit any transaction but error out if writes or callbacks are pending.
Definition: DBConnRef.php:503
Wikimedia\Rdbms\DatabaseDomain
Class to handle database/prefix specification for IDatabase domains.
Definition: DatabaseDomain.php:28
Wikimedia\Rdbms\DBConnRef\__construct
__construct(ILoadBalancer $lb, $conn)
Definition: DBConnRef.php:31
Wikimedia\Rdbms\DBConnRef\clearFlag
clearFlag( $flag, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
Definition: DBConnRef.php:135
Wikimedia\Rdbms\DBConnRef\commit
commit( $fname=__METHOD__, $flush='')
Commits a transaction previously started using begin().
Definition: DBConnRef.php:495
Wikimedia\Rdbms\DBConnRef\lockIsFree
lockIsFree( $lockName, $method)
Check to see if a named lock is available (non-blocking)
Definition: DBConnRef.php:553
Wikimedia\Rdbms\DBConnRef\onTransactionIdle
onTransactionIdle(callable $callback, $fname=__METHOD__)
Run a callback as soon as there is no transaction pending.
Definition: DBConnRef.php:467
Wikimedia\Rdbms\DBConnRef\fetchRow
fetchRow( $res)
Fetch the next row from the given result object, in associative array form.
Definition: DBConnRef.php:177
Wikimedia\Rdbms\DBConnRef\lastErrno
lastErrno()
Get the last error number.
Definition: DBConnRef.php:201
Wikimedia\Rdbms\DBConnRef\estimateRowCount
estimateRowCount( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=[])
Estimate the number of rows in dataset.
Definition: DBConnRef.php:278
Wikimedia\Rdbms\DBConnRef\namedLocksEnqueue
namedLocksEnqueue()
Check to see if a named lock used by lock() use blocking queues.
Definition: DBConnRef.php:569
Wikimedia\Rdbms\DBConnRef\getServerVersion
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
Definition: DBConnRef.php:221
Wikimedia\Rdbms\DBConnRef\begin
begin( $fname=__METHOD__, $mode=IDatabase::TRANSACTION_EXPLICIT)
Begin a transaction.
Definition: DBConnRef.php:491
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
Definition: hooks.txt:1049
Wikimedia\Rdbms\DBConnRef\wasErrorReissuable
wasErrorReissuable()
Determines if the last query error was due to a dropped connection and should be dealt with by pingin...
Definition: DBConnRef.php:439
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:79
Wikimedia\Rdbms\DBConnRef\bitAnd
bitAnd( $fieldLeft, $fieldRight)
Definition: DBConnRef.php:330
Wikimedia\Rdbms\DBConnRef\__call
__call( $name, array $arguments)
Definition: DBConnRef.php:42
Wikimedia\Rdbms\DBConnRef\indexUnique
indexUnique( $table, $index)
Determines if a given index is unique.
Definition: DBConnRef.php:302
$buffer
$buffer
Definition: mwdoc-filter.php:48
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Wikimedia\Rdbms\DBConnRef\aggregateValue
aggregateValue( $valuedata, $valuename='value')
Return aggregated value alias.
Definition: DBConnRef.php:322