MediaWiki  REL1_31
DatabaseMysqlBaseTest.php
Go to the documentation of this file.
1 <?php
27 use Wikimedia\TestingAccessWrapper;
28 
29 class 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  self::createUnicodeString( '`\u0001a\uFFFFb`' ),
83  self::createUnicodeString( '\u0001a\uFFFFb' )
84  ],
85  [
86  self::createUnicodeString( '`\u0001\uFFFF`' ),
87  self::createUnicodeString( '\u0001\u0000\uFFFF\u0000' )
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 static function createUnicodeString( $str ) {
101  return json_decode( '"' . $str . '"' );
102  }
103 
104  private function getMockForViews() {
105  $db = $this->getMockBuilder( DatabaseMysqli::class )
106  ->disableOriginalConstructor()
107  ->setMethods( [ 'fetchRow', 'query' ] )
108  ->getMock();
109 
110  $db->method( 'query' )
111  ->with( $this->anything() )
112  ->willReturn( new FakeResultWrapper( [
113  (object)[ 'Tables_in_' => 'view1' ],
114  (object)[ 'Tables_in_' => 'view2' ],
115  (object)[ 'Tables_in_' => 'myview' ]
116  ] ) );
117 
118  return $db;
119  }
120 
124  public function testListviews() {
125  $db = $this->getMockForViews();
126 
127  $this->assertEquals( [ 'view1', 'view2', 'myview' ],
128  $db->listViews() );
129 
130  // Prefix filtering
131  $this->assertEquals( [ 'view1', 'view2' ],
132  $db->listViews( 'view' ) );
133  $this->assertEquals( [ 'myview' ],
134  $db->listViews( 'my' ) );
135  $this->assertEquals( [],
136  $db->listViews( 'UNUSED_PREFIX' ) );
137  $this->assertEquals( [ 'view1', 'view2', 'myview' ],
138  $db->listViews( '' ) );
139  }
140 
144  public function testBinLogName() {
145  $pos = new MySQLMasterPos( "db1052.2424/4643", 1 );
146 
147  $this->assertEquals( "db1052", $pos->getLogName() );
148  $this->assertEquals( "db1052.2424", $pos->getLogFile() );
149  $this->assertEquals( [ 2424, 4643 ], $pos->getLogPosition() );
150  }
151 
156  public function testHasReached(
157  MySQLMasterPos $lowerPos, MySQLMasterPos $higherPos, $match, $hetero
158  ) {
159  if ( $match ) {
160  $this->assertTrue( $lowerPos->channelsMatch( $higherPos ) );
161 
162  if ( $hetero ) {
163  // Each position is has one channel higher than the other
164  $this->assertFalse( $higherPos->hasReached( $lowerPos ) );
165  } else {
166  $this->assertTrue( $higherPos->hasReached( $lowerPos ) );
167  }
168  $this->assertTrue( $lowerPos->hasReached( $lowerPos ) );
169  $this->assertTrue( $higherPos->hasReached( $higherPos ) );
170  $this->assertFalse( $lowerPos->hasReached( $higherPos ) );
171  } else { // channels don't match
172  $this->assertFalse( $lowerPos->channelsMatch( $higherPos ) );
173 
174  $this->assertFalse( $higherPos->hasReached( $lowerPos ) );
175  $this->assertFalse( $lowerPos->hasReached( $higherPos ) );
176  }
177  }
178 
179  public static function provideComparePositions() {
180  $now = microtime( true );
181 
182  return [
183  // Binlog style
184  [
185  new MySQLMasterPos( 'db1034-bin.000976/843431247', $now ),
186  new MySQLMasterPos( 'db1034-bin.000976/843431248', $now ),
187  true,
188  false
189  ],
190  [
191  new MySQLMasterPos( 'db1034-bin.000976/999', $now ),
192  new MySQLMasterPos( 'db1034-bin.000976/1000', $now ),
193  true,
194  false
195  ],
196  [
197  new MySQLMasterPos( 'db1034-bin.000976/999', $now ),
198  new MySQLMasterPos( 'db1035-bin.000976/1000', $now ),
199  false,
200  false
201  ],
202  // MySQL GTID style
203  [
204  new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-23', $now ),
205  new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:5-24', $now ),
206  true,
207  false
208  ],
209  [
210  new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:5-99', $now ),
211  new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-100', $now ),
212  true,
213  false
214  ],
215  [
216  new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:1-99', $now ),
217  new MySQLMasterPos( '1E11FA47-71CA-11E1-9E33-C80AA9429562:1-100', $now ),
218  false,
219  false
220  ],
221  // MariaDB GTID style
222  [
223  new MySQLMasterPos( '255-11-23', $now ),
224  new MySQLMasterPos( '255-11-24', $now ),
225  true,
226  false
227  ],
228  [
229  new MySQLMasterPos( '255-11-99', $now ),
230  new MySQLMasterPos( '255-11-100', $now ),
231  true,
232  false
233  ],
234  [
235  new MySQLMasterPos( '255-11-999', $now ),
236  new MySQLMasterPos( '254-11-1000', $now ),
237  false,
238  false
239  ],
240  [
241  new MySQLMasterPos( '255-11-23,256-12-50', $now ),
242  new MySQLMasterPos( '255-11-24', $now ),
243  true,
244  false
245  ],
246  [
247  new MySQLMasterPos( '255-11-99,256-12-50,257-12-50', $now ),
248  new MySQLMasterPos( '255-11-1000', $now ),
249  true,
250  false
251  ],
252  [
253  new MySQLMasterPos( '255-11-23,256-12-50', $now ),
254  new MySQLMasterPos( '255-11-24,155-52-63', $now ),
255  true,
256  false
257  ],
258  [
259  new MySQLMasterPos( '255-11-99,256-12-50,257-12-50', $now ),
260  new MySQLMasterPos( '255-11-1000,256-12-51', $now ),
261  true,
262  false
263  ],
264  [
265  new MySQLMasterPos( '255-11-99,256-12-50', $now ),
266  new MySQLMasterPos( '255-13-1000,256-14-49', $now ),
267  true,
268  true
269  ],
270  [
271  new MySQLMasterPos( '253-11-999,255-11-999', $now ),
272  new MySQLMasterPos( '254-11-1000', $now ),
273  false,
274  false
275  ],
276  ];
277  }
278 
283  public function testChannelsMatch( MySQLMasterPos $pos1, MySQLMasterPos $pos2, $matches ) {
284  $this->assertEquals( $matches, $pos1->channelsMatch( $pos2 ) );
285  $this->assertEquals( $matches, $pos2->channelsMatch( $pos1 ) );
286 
287  $roundtripPos = new MySQLMasterPos( (string)$pos1, 1 );
288  $this->assertEquals( (string)$pos1, (string)$roundtripPos );
289  }
290 
291  public static function provideChannelPositions() {
292  $now = microtime( true );
293 
294  return [
295  [
296  new MySQLMasterPos( 'db1034-bin.000876/44', $now ),
297  new MySQLMasterPos( 'db1034-bin.000976/74', $now ),
298  true
299  ],
300  [
301  new MySQLMasterPos( 'db1052-bin.000976/999', $now ),
302  new MySQLMasterPos( 'db1052-bin.000976/1000', $now ),
303  true
304  ],
305  [
306  new MySQLMasterPos( 'db1066-bin.000976/9999', $now ),
307  new MySQLMasterPos( 'db1035-bin.000976/10000', $now ),
308  false
309  ],
310  [
311  new MySQLMasterPos( 'db1066-bin.000976/9999', $now ),
312  new MySQLMasterPos( 'trump2016.000976/10000', $now ),
313  false
314  ],
315  ];
316  }
317 
322  public function testCommonGtidDomains( MySQLMasterPos $pos, MySQLMasterPos $ref, $gtids ) {
323  $this->assertEquals( $gtids, MySQLMasterPos::getCommonDomainGTIDs( $pos, $ref ) );
324  }
325 
326  public static function provideCommonDomainGTIDs() {
327  return [
328  [
329  new MySQLMasterPos( '255-13-99,256-12-50,257-14-50', 1 ),
330  new MySQLMasterPos( '255-11-1000', 1 ),
331  [ '255-13-99' ]
332  ],
333  [
334  new MySQLMasterPos(
335  '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-5,' .
336  '3E11FA47-71CA-11E1-9E33-C80AA9429562:20-99,' .
337  '7E11FA47-71CA-11E1-9E33-C80AA9429562:1-30',
338  1
339  ),
340  new MySQLMasterPos(
341  '1E11FA47-71CA-11E1-9E33-C80AA9429562:30-100,' .
342  '3E11FA47-71CA-11E1-9E33-C80AA9429562:30-66',
343  1
344  ),
345  [ '3E11FA47-71CA-11E1-9E33-C80AA9429562:20-99' ]
346  ]
347  ];
348  }
349 
355  public function testPtHeartbeat( $lag ) {
356  $db = $this->getMockBuilder( DatabaseMysqli::class )
357  ->disableOriginalConstructor()
358  ->setMethods( [
359  'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] )
360  ->getMock();
361 
362  $db->method( 'getLagDetectionMethod' )
363  ->willReturn( 'pt-heartbeat' );
364 
365  $db->method( 'getMasterServerInfo' )
366  ->willReturn( [ 'serverId' => 172, 'asOf' => time() ] );
367 
368  // Fake the current time.
369  list( $nowSecFrac, $nowSec ) = explode( ' ', microtime() );
370  $now = (float)$nowSec + (float)$nowSecFrac;
371  // Fake the heartbeat time.
372  // Work arounds for weak DataTime microseconds support.
373  $ptTime = $now - $lag;
374  $ptSec = (int)$ptTime;
375  $ptSecFrac = ( $ptTime - $ptSec );
376  $ptDateTime = new DateTime( "@$ptSec" );
377  $ptTimeISO = $ptDateTime->format( 'Y-m-d\TH:i:s' );
378  $ptTimeISO .= ltrim( number_format( $ptSecFrac, 6 ), '0' );
379 
380  $db->method( 'getHeartbeatData' )
381  ->with( [ 'server_id' => 172 ] )
382  ->willReturn( [ $ptTimeISO, $now ] );
383 
384  $db->setLBInfo( 'clusterMasterHost', 'db1052' );
385  $lagEst = $db->getLag();
386 
387  $this->assertGreaterThan( $lag - 0.010, $lagEst, "Correct heatbeat lag" );
388  $this->assertLessThan( $lag + 0.010, $lagEst, "Correct heatbeat lag" );
389  }
390 
391  public static function provideLagAmounts() {
392  return [
393  [ 0 ],
394  [ 0.3 ],
395  [ 6.5 ],
396  [ 10.1 ],
397  [ 200.2 ],
398  [ 400.7 ],
399  [ 600.22 ],
400  [ 1000.77 ],
401  ];
402  }
403 
410  public function testServerGtidTable( $gtable, $rBLtable, $mBLtable, $rGTIDs, $mGTIDs ) {
411  $db = $this->getMockBuilder( DatabaseMysqli::class )
412  ->disableOriginalConstructor()
413  ->setMethods( [
414  'useGTIDs',
415  'getServerGTIDs',
416  'getServerRoleStatus',
417  'getServerId',
418  'getServerUUID'
419  ] )
420  ->getMock();
421 
422  $db->method( 'useGTIDs' )->willReturn( true );
423  $db->method( 'getServerGTIDs' )->willReturn( $gtable );
424  $db->method( 'getServerRoleStatus' )->willReturnCallback(
425  function ( $role ) use ( $rBLtable, $mBLtable ) {
426  if ( $role === 'SLAVE' ) {
427  return $rBLtable;
428  } elseif ( $role === 'MASTER' ) {
429  return $mBLtable;
430  }
431 
432  return null;
433  }
434  );
435  $db->method( 'getServerId' )->willReturn( 1 );
436  $db->method( 'getServerUUID' )->willReturn( '2E11FA47-71CA-11E1-9E33-C80AA9429562' );
437 
438  if ( is_array( $rGTIDs ) ) {
439  $this->assertEquals( $rGTIDs, $db->getReplicaPos()->getGTIDs() );
440  } else {
441  $this->assertEquals( false, $db->getReplicaPos() );
442  }
443  if ( is_array( $mGTIDs ) ) {
444  $this->assertEquals( $mGTIDs, $db->getMasterPos()->getGTIDs() );
445  } else {
446  $this->assertEquals( false, $db->getMasterPos() );
447  }
448  }
449 
450  public static function provideGtidData() {
451  return [
452  // MariaDB
453  [
454  [
455  'gtid_domain_id' => 100,
456  'gtid_current_pos' => '100-13-77',
457  'gtid_binlog_pos' => '100-13-77',
458  'gtid_slave_pos' => null // master
459  ],
460  [
461  'Relay_Master_Log_File' => 'host.1600',
462  'Exec_Master_Log_Pos' => '77'
463  ],
464  [
465  'File' => 'host.1600',
466  'Position' => '77'
467  ],
468  [],
469  [ '100' => '100-13-77' ]
470  ],
471  [
472  [
473  'gtid_domain_id' => 100,
474  'gtid_current_pos' => '100-13-77',
475  'gtid_binlog_pos' => '100-13-77',
476  'gtid_slave_pos' => '100-13-77' // replica
477  ],
478  [
479  'Relay_Master_Log_File' => 'host.1600',
480  'Exec_Master_Log_Pos' => '77'
481  ],
482  [],
483  [ '100' => '100-13-77' ],
484  [ '100' => '100-13-77' ]
485  ],
486  [
487  [
488  'gtid_current_pos' => '100-13-77',
489  'gtid_binlog_pos' => '100-13-77',
490  'gtid_slave_pos' => '100-13-77' // replica
491  ],
492  [
493  'Relay_Master_Log_File' => 'host.1600',
494  'Exec_Master_Log_Pos' => '77'
495  ],
496  [],
497  [ '100' => '100-13-77' ],
498  [ '100' => '100-13-77' ]
499  ],
500  // MySQL
501  [
502  [
503  'gtid_executed' => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77'
504  ],
505  [
506  'Relay_Master_Log_File' => 'host.1600',
507  'Exec_Master_Log_Pos' => '77'
508  ],
509  [], // only a replica
510  [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
511  => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77' ],
512  // replica/master use same var
513  [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
514  => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-77' ],
515  ],
516  [
517  [
518  'gtid_executed' => '2E11FA47-71CA-11E1-9E33-C80AA9429562:1-49,' .
519  '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77'
520  ],
521  [
522  'Relay_Master_Log_File' => 'host.1600',
523  'Exec_Master_Log_Pos' => '77'
524  ],
525  [], // only a replica
526  [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
527  => '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77' ],
528  // replica/master use same var
529  [ '2E11FA47-71CA-11E1-9E33-C80AA9429562'
530  => '2E11FA47-71CA-11E1-9E33-C80AA9429562:51-77' ],
531  ],
532  [
533  [
534  'gtid_executed' => null, // not enabled?
535  'gtid_binlog_pos' => null
536  ],
537  [
538  'Relay_Master_Log_File' => 'host.1600',
539  'Exec_Master_Log_Pos' => '77'
540  ],
541  [], // only a replica
542  [], // binlog fallback
543  false
544  ],
545  [
546  [
547  'gtid_executed' => null, // not enabled?
548  'gtid_binlog_pos' => null
549  ],
550  [], // no replication
551  [], // no replication
552  false,
553  false
554  ]
555  ];
556  }
557 
561  public function testSerialize() {
562  $pos = new MySQLMasterPos( '3E11FA47-71CA-11E1-9E33-C80AA9429562:99', 53636363 );
563  $roundtripPos = unserialize( serialize( $pos ) );
564 
565  $this->assertEquals( $pos, $roundtripPos );
566 
567  $pos = new MySQLMasterPos( '255-11-23', 53636363 );
568  $roundtripPos = unserialize( serialize( $pos ) );
569 
570  $this->assertEquals( $pos, $roundtripPos );
571  }
572 
577  public function testInsertSelectIsSafe( $insertOpts, $selectOpts, $row, $safe ) {
578  $db = $this->getMockBuilder( DatabaseMysqli::class )
579  ->disableOriginalConstructor()
580  ->setMethods( [ 'getReplicationSafetyInfo' ] )
581  ->getMock();
582  $db->method( 'getReplicationSafetyInfo' )->willReturn( (object)$row );
583  $dbw = TestingAccessWrapper::newFromObject( $db );
584 
585  $this->assertEquals( $safe, $dbw->isInsertSelectSafe( $insertOpts, $selectOpts ) );
586  }
587 
588  public function provideInsertSelectCases() {
589  return [
590  [
591  [],
592  [],
593  [
594  'innodb_autoinc_lock_mode' => '2',
595  'binlog_format' => 'ROW',
596  ],
597  true
598  ],
599  [
600  [],
601  [ 'LIMIT' => 100 ],
602  [
603  'innodb_autoinc_lock_mode' => '2',
604  'binlog_format' => 'ROW',
605  ],
606  true
607  ],
608  [
609  [],
610  [ 'LIMIT' => 100 ],
611  [
612  'innodb_autoinc_lock_mode' => '0',
613  'binlog_format' => 'STATEMENT',
614  ],
615  false
616  ],
617  [
618  [],
619  [],
620  [
621  'innodb_autoinc_lock_mode' => '2',
622  'binlog_format' => 'STATEMENT',
623  ],
624  false
625  ],
626  [
627  [ 'NO_AUTO_COLUMNS' ],
628  [ 'LIMIT' => 100 ],
629  [
630  'innodb_autoinc_lock_mode' => '0',
631  'binlog_format' => 'STATEMENT',
632  ],
633  false
634  ],
635  [
636  [],
637  [],
638  [
639  'innodb_autoinc_lock_mode' => 0,
640  'binlog_format' => 'STATEMENT',
641  ],
642  true
643  ],
644  [
645  [ 'NO_AUTO_COLUMNS' ],
646  [],
647  [
648  'innodb_autoinc_lock_mode' => 2,
649  'binlog_format' => 'STATEMENT',
650  ],
651  true
652  ],
653  [
654  [ 'NO_AUTO_COLUMNS' ],
655  [],
656  [
657  'innodb_autoinc_lock_mode' => 0,
658  'binlog_format' => 'STATEMENT',
659  ],
660  true
661  ],
662 
663  ];
664  }
665 
669  public function testBuildIntegerCast() {
670  $db = $this->getMockBuilder( DatabaseMysqli::class )
671  ->disableOriginalConstructor()
672  ->setMethods( null )
673  ->getMock();
674  $output = $db->buildIntegerCast( 'fieldName' );
675  $this->assertSame( 'CAST( fieldName AS SIGNED )', $output );
676  }
677 
678  /*
679  * @covers Wikimedia\Rdbms\Database::setIndexAliases
680  */
681  public function testIndexAliases() {
682  $db = $this->getMockBuilder( DatabaseMysqli::class )
683  ->disableOriginalConstructor()
684  ->setMethods( [ 'mysqlRealEscapeString' ] )
685  ->getMock();
686  $db->method( 'mysqlRealEscapeString' )->willReturnCallback(
687  function ( $s ) {
688  return str_replace( "'", "\\'", $s );
689  }
690  );
691 
692  $db->setIndexAliases( [ 'a_b_idx' => 'a_c_idx' ] );
693  $sql = $db->selectSQLText(
694  'zend', 'field', [ 'a' => 'x' ], __METHOD__, [ 'USE INDEX' => 'a_b_idx' ] );
695 
696  $this->assertEquals(
697  "SELECT field FROM `zend` FORCE INDEX (a_c_idx) WHERE a = 'x' ",
698  $sql
699  );
700 
701  $db->setIndexAliases( [] );
702  $sql = $db->selectSQLText(
703  'zend', 'field', [ 'a' => 'x' ], __METHOD__, [ 'USE INDEX' => 'a_b_idx' ] );
704 
705  $this->assertEquals(
706  "SELECT field FROM `zend` FORCE INDEX (a_b_idx) WHERE a = 'x' ",
707  $sql
708  );
709  }
710 
714  public function testTableAliases() {
715  $db = $this->getMockBuilder( DatabaseMysqli::class )
716  ->disableOriginalConstructor()
717  ->setMethods( [ 'mysqlRealEscapeString' ] )
718  ->getMock();
719  $db->method( 'mysqlRealEscapeString' )->willReturnCallback(
720  function ( $s ) {
721  return str_replace( "'", "\\'", $s );
722  }
723  );
724 
725  $db->setTableAliases( [
726  'meow' => [ 'dbname' => 'feline', 'schema' => null, 'prefix' => 'cat_' ]
727  ] );
728  $sql = $db->selectSQLText( 'meow', 'field', [ 'a' => 'x' ], __METHOD__ );
729 
730  $this->assertEquals(
731  "SELECT field FROM `feline`.`cat_meow` WHERE a = 'x' ",
732  $sql
733  );
734 
735  $db->setTableAliases( [] );
736  $sql = $db->selectSQLText( 'meow', 'field', [ 'a' => 'x' ], __METHOD__ );
737 
738  $this->assertEquals(
739  "SELECT field FROM `meow` WHERE a = 'x' ",
740  $sql
741  );
742  }
743 }
DatabaseMysqlBaseTest\getMockForViews
getMockForViews()
Definition: DatabaseMysqlBaseTest.php:104
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
DatabaseMysqlBaseTest\provideGtidData
static provideGtidData()
Definition: DatabaseMysqlBaseTest.php:450
$output
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2255
DatabaseMysqlBaseTest\provideLagAmounts
static provideLagAmounts()
Definition: DatabaseMysqlBaseTest.php:391
DatabaseMysqlBaseTest\testBuildIntegerCast
testBuildIntegerCast()
\Wikimedia\Rdbms\DatabaseMysqlBase::buildIntegerCast
Definition: DatabaseMysqlBaseTest.php:669
DatabaseMysqlBaseTest\testHasReached
testHasReached(MySQLMasterPos $lowerPos, MySQLMasterPos $higherPos, $match, $hetero)
provideComparePositions Wikimedia\Rdbms\MySQLMasterPos
Definition: DatabaseMysqlBaseTest.php:156
DatabaseMysqlBaseTest\testChannelsMatch
testChannelsMatch(MySQLMasterPos $pos1, MySQLMasterPos $pos2, $matches)
provideChannelPositions Wikimedia\Rdbms\MySQLMasterPos
Definition: DatabaseMysqlBaseTest.php:283
anything
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
Definition: distributors.txt:45
unserialize
unserialize( $serialized)
Definition: ApiMessage.php:192
DatabaseMysqlBaseTest\testIndexAliases
testIndexAliases()
Definition: DatabaseMysqlBaseTest.php:681
DatabaseMysqlBaseTest\provideComparePositions
static provideComparePositions()
Definition: DatabaseMysqlBaseTest.php:179
serialize
serialize()
Definition: ApiMessage.php:184
$s
$s
Definition: mergeMessageFileList.php:187
DatabaseMysqlBaseTest\testInsertSelectIsSafe
testInsertSelectIsSafe( $insertOpts, $selectOpts, $row, $safe)
Wikimedia\Rdbms\DatabaseMysqlBase::isInsertSelectSafe provideInsertSelectCases.
Definition: DatabaseMysqlBaseTest.php:577
DatabaseMysqlBaseTest\testSerialize
testSerialize()
Wikimedia\Rdbms\MySQLMasterPos.
Definition: DatabaseMysqlBaseTest.php:561
DatabaseMysqlBaseTest
Definition: DatabaseMysqlBaseTest.php:29
DatabaseMysqlBaseTest\provideCommonDomainGTIDs
static provideCommonDomainGTIDs()
Definition: DatabaseMysqlBaseTest.php:326
true
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:2006
DatabaseMysqlBaseTest\testPtHeartbeat
testPtHeartbeat( $lag)
provideLagAmounts Wikimedia\Rdbms\DatabaseMysqlBase::getLag Wikimedia\Rdbms\DatabaseMysqlBase::getLag...
Definition: DatabaseMysqlBaseTest.php:355
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:37
Wikimedia\Rdbms\MySQLMasterPos\channelsMatch
channelsMatch(DBMasterPos $pos)
Definition: MySQLMasterPos.php:137
DatabaseMysqlBaseTest\testServerGtidTable
testServerGtidTable( $gtable, $rBLtable, $mBLtable, $rGTIDs, $mGTIDs)
provideGtidData Wikimedia\Rdbms\MySQLMasterPos Wikimedia\Rdbms\DatabaseMysqlBase::getReplicaPos Wikim...
Definition: DatabaseMysqlBaseTest.php:410
Wikimedia\Rdbms\MySQLMasterPos\hasReached
hasReached(DBMasterPos $pos)
Definition: MySQLMasterPos.php:103
$matches
$matches
Definition: NoLocalSettings.php:24
Wikimedia\Rdbms\MySQLMasterPos
DBMasterPos class for MySQL/MariaDB.
Definition: MySQLMasterPos.php:19
DatabaseMysqlBaseTest\testBinLogName
testBinLogName()
Wikimedia\Rdbms\MySQLMasterPos.
Definition: DatabaseMysqlBaseTest.php:144
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
DatabaseMysqlBaseTest\testTableAliases
testTableAliases()
Wikimedia\Rdbms\Database::setTableAliases.
Definition: DatabaseMysqlBaseTest.php:714
DatabaseMysqlBaseTest\createUnicodeString
static createUnicodeString( $str)
Definition: DatabaseMysqlBaseTest.php:100
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:56
DatabaseMysqlBaseTest\provideChannelPositions
static provideChannelPositions()
Definition: DatabaseMysqlBaseTest.php:291
DatabaseMysqlBaseTest\testCommonGtidDomains
testCommonGtidDomains(MySQLMasterPos $pos, MySQLMasterPos $ref, $gtids)
provideCommonDomainGTIDs Wikimedia\Rdbms\MySQLMasterPos
Definition: DatabaseMysqlBaseTest.php:322
DatabaseMysqlBaseTest\provideInsertSelectCases
provideInsertSelectCases()
Definition: DatabaseMysqlBaseTest.php:588
DatabaseMysqlBaseTest\testListviews
testListviews()
Wikimedia\Rdbms\DatabaseMysqlBase::listViews.
Definition: DatabaseMysqlBaseTest.php:124
DatabaseMysqlBaseTest\provideDiapers
static provideDiapers()
Feeds testAddIdentifierQuotes.
Definition: DatabaseMysqlBaseTest.php:53
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
DatabaseMysqlBaseTest\testAddIdentifierQuotes
testAddIdentifierQuotes( $expected, $in)
provideDiapers Wikimedia\Rdbms\DatabaseMysqlBase::addIdentifierQuotes
Definition: DatabaseMysqlBaseTest.php:38