MediaWiki REL1_33
DatabaseMysqlBaseTest.php
Go to the documentation of this file.
1<?php
27use Wikimedia\TestingAccessWrapper;
28
29class DatabaseMysqlBaseTest extends PHPUnit\Framework\TestCase {
30
31 use MediaWikiCoversValidator;
32 use PHPUnit4And6Compat;
33
38 public function testAddIdentifierQuotes( $expected, $in ) {
39 $db = $this->getMockBuilder( DatabaseMysqli::class )
40 ->disableOriginalConstructor()
41 ->setMethods( null )
42 ->getMock();
43
44 $quoted = $db->addIdentifierQuotes( $in );
45 $this->assertEquals( $expected, $quoted );
46 }
47
53 public static function provideDiapers() {
54 return [
55 // Format: expected, input
56 [ '``', '' ],
57
58 // Yeah I really hate loosely typed PHP idiocies nowadays
59 [ '``', null ],
60
61 // Dear codereviewer, guess what addIdentifierQuotes()
62 // will return with thoses:
63 [ '``', false ],
64 [ '`1`', true ],
65
66 // We never know what could happen
67 [ '`0`', 0 ],
68 [ '`1`', 1 ],
69
70 // Whatchout! Should probably use something more meaningful
71 [ "`'`", "'" ], # single quote
72 [ '`"`', '"' ], # double quote
73 [ '````', '`' ], # backtick
74 [ '`’`', '’' ], # apostrophe (look at your encyclopedia)
75
76 // sneaky NUL bytes are lurking everywhere
77 [ '``', "\0" ],
78 [ '`xyzzy`', "\0x\0y\0z\0z\0y\0" ],
79
80 // unicode chars
81 [
82 "`\u{0001}a\u{FFFF}b`",
83 "\u{0001}a\u{FFFF}b"
84 ],
85 [
86 "`\u{0001}\u{FFFF}`",
87 "\u{0001}\u{0000}\u{FFFF}\u{0000}"
88 ],
89 [ '`☃`', '☃' ],
90 [ '`メインページ`', 'メインページ' ],
91 [ '`Басты_бет`', 'Басты_бет' ],
92
93 // Real world:
94 [ '`Alix`', 'Alix' ], # while( ! $recovered ) { sleep(); }
95 [ '`Backtick: ```', 'Backtick: `' ],
96 [ '`This is a test`', 'This is a test' ],
97 ];
98 }
99
100 private function getMockForViews() {
101 $db = $this->getMockBuilder( DatabaseMysqli::class )
102 ->disableOriginalConstructor()
103 ->setMethods( [ 'fetchRow', 'query', 'getDBname' ] )
104 ->getMock();
105
106 $db->method( 'query' )
107 ->with( $this->anything() )
108 ->willReturn( new FakeResultWrapper( [
109 (object)[ 'Tables_in_' => 'view1' ],
110 (object)[ 'Tables_in_' => 'view2' ],
111 (object)[ 'Tables_in_' => 'myview' ]
112 ] ) );
113 $db->method( 'getDBname' )->willReturn( '' );
114
115 return $db;
116 }
117
121 public function testListviews() {
122 $db = $this->getMockForViews();
123
124 $this->assertEquals( [ 'view1', 'view2', 'myview' ],
125 $db->listViews() );
126
127 // Prefix filtering
128 $this->assertEquals( [ 'view1', 'view2' ],
129 $db->listViews( 'view' ) );
130 $this->assertEquals( [ 'myview' ],
131 $db->listViews( 'my' ) );
132 $this->assertEquals( [],
133 $db->listViews( 'UNUSED_PREFIX' ) );
134 $this->assertEquals( [ 'view1', 'view2', 'myview' ],
135 $db->listViews( '' ) );
136 }
137
141 public function testBinLogName() {
142 $pos = new MySQLMasterPos( "db1052.2424/4643", 1 );
143
144 $this->assertEquals( "db1052", $pos->getLogName() );
145 $this->assertEquals( "db1052.2424", $pos->getLogFile() );
146 $this->assertEquals( [ 2424, 4643 ], $pos->getLogPosition() );
147 }
148
153 public function testHasReached(
154 MySQLMasterPos $lowerPos, MySQLMasterPos $higherPos, $match, $hetero
155 ) {
156 if ( $match ) {
157 $this->assertTrue( $lowerPos->channelsMatch( $higherPos ) );
158
159 if ( $hetero ) {
160 // Each position is has one channel higher than the other
161 $this->assertFalse( $higherPos->hasReached( $lowerPos ) );
162 } else {
163 $this->assertTrue( $higherPos->hasReached( $lowerPos ) );
164 }
165 $this->assertTrue( $lowerPos->hasReached( $lowerPos ) );
166 $this->assertTrue( $higherPos->hasReached( $higherPos ) );
167 $this->assertFalse( $lowerPos->hasReached( $higherPos ) );
168 } else { // channels don't match
169 $this->assertFalse( $lowerPos->channelsMatch( $higherPos ) );
170
171 $this->assertFalse( $higherPos->hasReached( $lowerPos ) );
172 $this->assertFalse( $lowerPos->hasReached( $higherPos ) );
173 }
174 }
175
176 public static function provideComparePositions() {
177 $now = microtime( true );
178
179 return [
180 // Binlog style
181 [
182 new MySQLMasterPos( 'db1034-bin.000976/843431247', $now ),
183 new MySQLMasterPos( 'db1034-bin.000976/843431248', $now ),
184 true,
185 false
186 ],
187 [
188 new MySQLMasterPos( 'db1034-bin.000976/999', $now ),
189 new MySQLMasterPos( 'db1034-bin.000976/1000', $now ),
190 true,
191 false
192 ],
193 [
194 new MySQLMasterPos( 'db1034-bin.000976/999', $now ),
195 new MySQLMasterPos( 'db1035-bin.000976/1000', $now ),
196 false,
197 false
198 ],
199 // MySQL GTID style
200 [
201 new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23', $now ),
202 new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:5-24', $now ),
203 true,
204 false
205 ],
206 [
207 new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:5-99', $now ),
208 new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100', $now ),
209 true,
210 false
211 ],
212 [
213 new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-99', $now ),
214 new MySQLMasterPos( '1E11FA47-71CA-11E1-9E33-C80AA9429562:1-100', $now ),
215 false,
216 false
217 ],
218 // MariaDB GTID style
219 [
220 new MySQLMasterPos( '255-11-23', $now ),
221 new MySQLMasterPos( '255-11-24', $now ),
222 true,
223 false
224 ],
225 [
226 new MySQLMasterPos( '255-11-99', $now ),
227 new MySQLMasterPos( '255-11-100', $now ),
228 true,
229 false
230 ],
231 [
232 new MySQLMasterPos( '255-11-999', $now ),
233 new MySQLMasterPos( '254-11-1000', $now ),
234 false,
235 false
236 ],
237 [
238 new MySQLMasterPos( '255-11-23,256-12-50', $now ),
239 new MySQLMasterPos( '255-11-24', $now ),
240 true,
241 false
242 ],
243 [
244 new MySQLMasterPos( '255-11-99,256-12-50,257-12-50', $now ),
245 new MySQLMasterPos( '255-11-1000', $now ),
246 true,
247 false
248 ],
249 [
250 new MySQLMasterPos( '255-11-23,256-12-50', $now ),
251 new MySQLMasterPos( '255-11-24,155-52-63', $now ),
252 true,
253 false
254 ],
255 [
256 new MySQLMasterPos( '255-11-99,256-12-50,257-12-50', $now ),
257 new MySQLMasterPos( '255-11-1000,256-12-51', $now ),
258 true,
259 false
260 ],
261 [
262 new MySQLMasterPos( '255-11-99,256-12-50', $now ),
263 new MySQLMasterPos( '255-13-1000,256-14-49', $now ),
264 true,
265 true
266 ],
267 [
268 new MySQLMasterPos( '253-11-999,255-11-999', $now ),
269 new MySQLMasterPos( '254-11-1000', $now ),
270 false,
271 false
272 ],
273 ];
274 }
275
280 public function testChannelsMatch( MySQLMasterPos $pos1, MySQLMasterPos $pos2, $matches ) {
281 $this->assertEquals( $matches, $pos1->channelsMatch( $pos2 ) );
282 $this->assertEquals( $matches, $pos2->channelsMatch( $pos1 ) );
283
284 $roundtripPos = new MySQLMasterPos( (string)$pos1, 1 );
285 $this->assertEquals( (string)$pos1, (string)$roundtripPos );
286 }
287
288 public static function provideChannelPositions() {
289 $now = microtime( true );
290
291 return [
292 [
293 new MySQLMasterPos( 'db1034-bin.000876/44', $now ),
294 new MySQLMasterPos( 'db1034-bin.000976/74', $now ),
295 true
296 ],
297 [
298 new MySQLMasterPos( 'db1052-bin.000976/999', $now ),
299 new MySQLMasterPos( 'db1052-bin.000976/1000', $now ),
300 true
301 ],
302 [
303 new MySQLMasterPos( 'db1066-bin.000976/9999', $now ),
304 new MySQLMasterPos( 'db1035-bin.000976/10000', $now ),
305 false
306 ],
307 [
308 new MySQLMasterPos( 'db1066-bin.000976/9999', $now ),
309 new MySQLMasterPos( 'trump2016.000976/10000', $now ),
310 false
311 ],
312 ];
313 }
314
319 public function testCommonGtidDomains( MySQLMasterPos $pos, MySQLMasterPos $ref, $gtids ) {
320 $this->assertEquals( $gtids, MySQLMasterPos::getCommonDomainGTIDs( $pos, $ref ) );
321 }
322
323 public static function provideCommonDomainGTIDs() {
324 return [
325 [
326 new MySQLMasterPos( '255-13-99,256-12-50,257-14-50', 1 ),
327 new MySQLMasterPos( '255-11-1000', 1 ),
328 [ '255-13-99' ]
329 ],
330 [
331 new MySQLMasterPos(
332 '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-5,' .
333 '3E11FA47-71CA-11E1-9E33-C80AA9429562:20-99,' .
334 '7E11FA47-71CA-11E1-9E33-C80AA9429562:1-30',
335 1
336 ),
337 new MySQLMasterPos(
338 '1E11FA47-71CA-11E1-9E33-C80AA9429562:30-100,' .
339 '3E11FA47-71CA-11E1-9E33-C80AA9429562:30-66',
340 1
341 ),
342 [ '3E11FA47-71CA-11E1-9E33-C80AA9429562:20-99' ]
343 ]
344 ];
345 }
346
352 public function testPtHeartbeat( $lag ) {
353 $db = $this->getMockBuilder( DatabaseMysqli::class )
354 ->disableOriginalConstructor()
355 ->setMethods( [
356 'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] )
357 ->getMock();
358
359 $db->method( 'getLagDetectionMethod' )
360 ->willReturn( 'pt-heartbeat' );
361
362 $db->method( 'getMasterServerInfo' )
363 ->willReturn( [ 'serverId' => 172, 'asOf' => time() ] );
364
365 // Fake the current time.
366 list( $nowSecFrac, $nowSec ) = explode( ' ', microtime() );
367 $now = (float)$nowSec + (float)$nowSecFrac;
368 // Fake the heartbeat time.
369 // Work arounds for weak DataTime microseconds support.
370 $ptTime = $now - $lag;
371 $ptSec = (int)$ptTime;
372 $ptSecFrac = ( $ptTime - $ptSec );
373 $ptDateTime = new DateTime( "@$ptSec" );
374 $ptTimeISO = $ptDateTime->format( 'Y-m-d\TH:i:s' );
375 $ptTimeISO .= ltrim( number_format( $ptSecFrac, 6 ), '0' );
376
377 $db->method( 'getHeartbeatData' )
378 ->with( [ 'server_id' => 172 ] )
379 ->willReturn( [ $ptTimeISO, $now ] );
380
381 $db->setLBInfo( 'clusterMasterHost', 'db1052' );
382 $lagEst = $db->getLag();
383
384 $this->assertGreaterThan( $lag - 0.010, $lagEst, "Correct heatbeat lag" );
385 $this->assertLessThan( $lag + 0.010, $lagEst, "Correct heatbeat lag" );
386 }
387
388 public static function provideLagAmounts() {
389 return [
390 [ 0 ],
391 [ 0.3 ],
392 [ 6.5 ],
393 [ 10.1 ],
394 [ 200.2 ],
395 [ 400.7 ],
396 [ 600.22 ],
397 [ 1000.77 ],
398 ];
399 }
400
407 public function testServerGtidTable( $gtable, $rBLtable, $mBLtable, $rGTIDs, $mGTIDs ) {
408 $db = $this->getMockBuilder( DatabaseMysqli::class )
409 ->disableOriginalConstructor()
410 ->setMethods( [
411 'useGTIDs',
412 'getServerGTIDs',
413 'getServerRoleStatus',
414 'getServerId',
415 'getServerUUID'
416 ] )
417 ->getMock();
418
419 $db->method( 'useGTIDs' )->willReturn( true );
420 $db->method( 'getServerGTIDs' )->willReturn( $gtable );
421 $db->method( 'getServerRoleStatus' )->willReturnCallback(
422 function ( $role ) use ( $rBLtable, $mBLtable ) {
423 if ( $role === 'SLAVE' ) {
424 return $rBLtable;
425 } elseif ( $role === 'MASTER' ) {
426 return $mBLtable;
427 }
428
429 return null;
430 }
431 );
432 $db->method( 'getServerId' )->willReturn( 1 );
433 $db->method( 'getServerUUID' )->willReturn( '2E11FA47-71CA-11E1-9E33-C80AA9429562' );
434
435 if ( is_array( $rGTIDs ) ) {
436 $this->assertEquals( $rGTIDs, $db->getReplicaPos()->getGTIDs() );
437 } else {
438 $this->assertEquals( false, $db->getReplicaPos() );
439 }
440 if ( is_array( $mGTIDs ) ) {
441 $this->assertEquals( $mGTIDs, $db->getMasterPos()->getGTIDs() );
442 } else {
443 $this->assertEquals( false, $db->getMasterPos() );
444 }
445 }
446
447 public static function provideGtidData() {
448 return [
449 // MariaDB
450 [
451 [
452 'gtid_domain_id' => 100,
453 'gtid_current_pos' => '100-13-77',
454 'gtid_binlog_pos' => '100-13-77',
455 'gtid_slave_pos' => null // master
456 ],
457 [
458 'Relay_Master_Log_File' => 'host.1600',
459 'Exec_Master_Log_Pos' => '77'
460 ],
461 [
462 'File' => 'host.1600',
463 'Position' => '77'
464 ],
465 [],
466 [ '100' => '100-13-77' ]
467 ],
468 [
469 [
470 'gtid_domain_id' => 100,
471 'gtid_current_pos' => '100-13-77',
472 'gtid_binlog_pos' => '100-13-77',
473 'gtid_slave_pos' => '100-13-77' // replica
474 ],
475 [
476 'Relay_Master_Log_File' => 'host.1600',
477 'Exec_Master_Log_Pos' => '77'
478 ],
479 [],
480 [ '100' => '100-13-77' ],
481 [ '100' => '100-13-77' ]
482 ],
483 [
484 [
485 'gtid_current_pos' => '100-13-77',
486 'gtid_binlog_pos' => '100-13-77',
487 'gtid_slave_pos' => '100-13-77' // replica
488 ],
489 [
490 'Relay_Master_Log_File' => 'host.1600',
491 'Exec_Master_Log_Pos' => '77'
492 ],
493 [],
494 [ '100' => '100-13-77' ],
495 [ '100' => '100-13-77' ]
496 ],
497 // MySQL
498 [
499 [
500 'gtid_executed' => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77'
501 ],
502 [
503 'Relay_Master_Log_File' => 'host.1600',
504 'Exec_Master_Log_Pos' => '77'
505 ],
506 [], // only a replica
507 [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
508 => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77' ],
509 // replica/master use same var
510 [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
511 => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77' ],
512 ],
513 [
514 [
515 'gtid_executed' => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-49,' .
516 '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77'
517 ],
518 [
519 'Relay_Master_Log_File' => 'host.1600',
520 'Exec_Master_Log_Pos' => '77'
521 ],
522 [], // only a replica
523 [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
524 => '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77' ],
525 // replica/master use same var
526 [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
527 => '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77' ],
528 ],
529 [
530 [
531 'gtid_executed' => null, // not enabled?
532 'gtid_binlog_pos' => null
533 ],
534 [
535 'Relay_Master_Log_File' => 'host.1600',
536 'Exec_Master_Log_Pos' => '77'
537 ],
538 [], // only a replica
539 [], // binlog fallback
540 false
541 ],
542 [
543 [
544 'gtid_executed' => null, // not enabled?
545 'gtid_binlog_pos' => null
546 ],
547 [], // no replication
548 [], // no replication
549 false,
550 false
551 ]
552 ];
553 }
554
558 public function testSerialize() {
559 $pos = new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:99', 53636363 );
560 $roundtripPos = unserialize( serialize( $pos ) );
561
562 $this->assertEquals( $pos, $roundtripPos );
563
564 $pos = new MySQLMasterPos( '255-11-23', 53636363 );
565 $roundtripPos = unserialize( serialize( $pos ) );
566
567 $this->assertEquals( $pos, $roundtripPos );
568 }
569
574 public function testInsertSelectIsSafe( $insertOpts, $selectOpts, $row, $safe ) {
575 $db = $this->getMockBuilder( DatabaseMysqli::class )
576 ->disableOriginalConstructor()
577 ->setMethods( [ 'getReplicationSafetyInfo' ] )
578 ->getMock();
579 $db->method( 'getReplicationSafetyInfo' )->willReturn( (object)$row );
580 $dbw = TestingAccessWrapper::newFromObject( $db );
581
582 $this->assertEquals( $safe, $dbw->isInsertSelectSafe( $insertOpts, $selectOpts ) );
583 }
584
585 public function provideInsertSelectCases() {
586 return [
587 [
588 [],
589 [],
590 [
591 'innodb_autoinc_lock_mode' => '2',
592 'binlog_format' => 'ROW',
593 ],
594 true
595 ],
596 [
597 [],
598 [ 'LIMIT' => 100 ],
599 [
600 'innodb_autoinc_lock_mode' => '2',
601 'binlog_format' => 'ROW',
602 ],
603 true
604 ],
605 [
606 [],
607 [ 'LIMIT' => 100 ],
608 [
609 'innodb_autoinc_lock_mode' => '0',
610 'binlog_format' => 'STATEMENT',
611 ],
612 false
613 ],
614 [
615 [],
616 [],
617 [
618 'innodb_autoinc_lock_mode' => '2',
619 'binlog_format' => 'STATEMENT',
620 ],
621 false
622 ],
623 [
624 [ 'NO_AUTO_COLUMNS' ],
625 [ 'LIMIT' => 100 ],
626 [
627 'innodb_autoinc_lock_mode' => '0',
628 'binlog_format' => 'STATEMENT',
629 ],
630 false
631 ],
632 [
633 [],
634 [],
635 [
636 'innodb_autoinc_lock_mode' => 0,
637 'binlog_format' => 'STATEMENT',
638 ],
639 true
640 ],
641 [
642 [ 'NO_AUTO_COLUMNS' ],
643 [],
644 [
645 'innodb_autoinc_lock_mode' => 2,
646 'binlog_format' => 'STATEMENT',
647 ],
648 true
649 ],
650 [
651 [ 'NO_AUTO_COLUMNS' ],
652 [],
653 [
654 'innodb_autoinc_lock_mode' => 0,
655 'binlog_format' => 'STATEMENT',
656 ],
657 true
658 ],
659
660 ];
661 }
662
666 public function testBuildIntegerCast() {
667 $db = $this->getMockBuilder( DatabaseMysqli::class )
668 ->disableOriginalConstructor()
669 ->setMethods( null )
670 ->getMock();
671 $output = $db->buildIntegerCast( 'fieldName' );
672 $this->assertSame( 'CAST( fieldName AS SIGNED )', $output );
673 }
674
678 public function testIndexAliases() {
679 $db = $this->getMockBuilder( DatabaseMysqli::class )
680 ->disableOriginalConstructor()
681 ->setMethods( [ 'mysqlRealEscapeString', 'dbSchema', 'tablePrefix' ] )
682 ->getMock();
683 $db->method( 'mysqlRealEscapeString' )->willReturnCallback(
684 function ( $s ) {
685 return str_replace( "'", "\\'", $s );
686 }
687 );
688
689 $db->setIndexAliases( [ 'a_b_idx' => 'a_c_idx' ] );
690 $sql = $db->selectSQLText(
691 'zend', 'field', [ 'a' => 'x' ], __METHOD__, [ 'USE INDEX' => 'a_b_idx' ] );
692
693 $this->assertEquals(
694 "SELECT field FROM `zend` FORCE INDEX (a_c_idx) WHERE a = 'x' ",
695 $sql
696 );
697
698 $db->setIndexAliases( [] );
699 $sql = $db->selectSQLText(
700 'zend', 'field', [ 'a' => 'x' ], __METHOD__, [ 'USE INDEX' => 'a_b_idx' ] );
701
702 $this->assertEquals(
703 "SELECT field FROM `zend` FORCE INDEX (a_b_idx) WHERE a = 'x' ",
704 $sql
705 );
706 }
707
711 public function testTableAliases() {
712 $db = $this->getMockBuilder( DatabaseMysqli::class )
713 ->disableOriginalConstructor()
714 ->setMethods( [ 'mysqlRealEscapeString', 'dbSchema', 'tablePrefix' ] )
715 ->getMock();
716 $db->method( 'mysqlRealEscapeString' )->willReturnCallback(
717 function ( $s ) {
718 return str_replace( "'", "\\'", $s );
719 }
720 );
721
722 $db->setTableAliases( [
723 'meow' => [ 'dbname' => 'feline', 'schema' => null, 'prefix' => 'cat_' ]
724 ] );
725 $sql = $db->selectSQLText( 'meow', 'field', [ 'a' => 'x' ], __METHOD__ );
726
727 $this->assertEquals(
728 "SELECT field FROM `feline`.`cat_meow` WHERE a = 'x' ",
729 $sql
730 );
731
732 $db->setTableAliases( [] );
733 $sql = $db->selectSQLText( 'meow', 'field', [ 'a' => 'x' ], __METHOD__ );
734
735 $this->assertEquals(
736 "SELECT field FROM `meow` WHERE a = 'x' ",
737 $sql
738 );
739 }
740}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
serialize()
unserialize( $serialized)
static provideDiapers()
Feeds testAddIdentifierQuotes.
testServerGtidTable( $gtable, $rBLtable, $mBLtable, $rGTIDs, $mGTIDs)
provideGtidData Wikimedia\Rdbms\MySQLMasterPos Wikimedia\Rdbms\DatabaseMysqlBase::getReplicaPos Wikim...
testPtHeartbeat( $lag)
provideLagAmounts Wikimedia\Rdbms\DatabaseMysqlBase::getLag Wikimedia\Rdbms\DatabaseMysqlBase::getLag...
testInsertSelectIsSafe( $insertOpts, $selectOpts, $row, $safe)
Wikimedia\Rdbms\DatabaseMysqlBase::isInsertSelectSafe provideInsertSelectCases.
testTableAliases()
Wikimedia\Rdbms\Database::setTableAliases.
testBuildIntegerCast()
\Wikimedia\Rdbms\DatabaseMysqlBase::buildIntegerCast
testAddIdentifierQuotes( $expected, $in)
provideDiapers Wikimedia\Rdbms\DatabaseMysqlBase::addIdentifierQuotes
testIndexAliases()
Wikimedia\Rdbms\Database::setIndexAliases.
testHasReached(MySQLMasterPos $lowerPos, MySQLMasterPos $higherPos, $match, $hetero)
provideComparePositions Wikimedia\Rdbms\MySQLMasterPos
testCommonGtidDomains(MySQLMasterPos $pos, MySQLMasterPos $ref, $gtids)
provideCommonDomainGTIDs Wikimedia\Rdbms\MySQLMasterPos
testSerialize()
Wikimedia\Rdbms\MySQLMasterPos.
testChannelsMatch(MySQLMasterPos $pos1, MySQLMasterPos $pos2, $matches)
provideChannelPositions Wikimedia\Rdbms\MySQLMasterPos
testBinLogName()
Wikimedia\Rdbms\MySQLMasterPos.
testListviews()
Wikimedia\Rdbms\DatabaseMysqlBase::listViews.
DBMasterPos class for MySQL/MariaDB.
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same so they can t rely on Unix and must forbid reads to even standard directories like tmp lest users read each others files We cannot assume that the user has the ability to install or run any programs not written as web accessible PHP scripts Since anything that works on cheap shared hosting will work if you have shell or root access MediaWiki s design is based around catering to the lowest common denominator Although we support higher end setups as the way many things work by default is tailored toward shared hosting These defaults are unconventional from the point of view of and they certainly aren t ideal for someone who s installing MediaWiki as MediaWiki does not conform to normal Unix filesystem layout Hopefully we ll offer direct support for standard layouts in the but for now *any change to the location of files is unsupported *Moving things and leaving symlinks will *probably *not break anything
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition hooks.txt:783
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition hooks.txt:2004
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2272
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
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:37