29 $WANObjectCache =
null
44 return $this->getMockBuilder( LoadBalancer::class )
45 ->disableOriginalConstructor()->getMock();
52 return $this->getMockBuilder( Database::class )
53 ->disableOriginalConstructor()->getMock();
60 return $this->getMockBuilder( SqlBlobStore::class )
61 ->disableOriginalConstructor()->getMock();
74 $this->assertTrue( $store->getContentHandlerUseDB() );
75 $store->setContentHandlerUseDB(
false );
76 $this->assertFalse( $store->getContentHandlerUseDB() );
77 $store->setContentHandlerUseDB(
true );
78 $this->assertTrue( $store->getContentHandlerUseDB() );
97 'rev_comment_text' =>
'rev_comment',
98 'rev_comment_data' =>
'NULL',
99 'rev_comment_cid' =>
'NULL',
105 'rev_user' =>
'rev_user',
106 'rev_user_text' =>
'rev_user_text',
107 'rev_actor' =>
'NULL',
113 'rev_content_format',
123 'tables' => [
'revision' ],
124 'fields' => array_merge(
137 'tables' => [
'revision' ],
138 'fields' => array_merge(
150 'tables' => [
'revision',
'page' ],
151 'fields' => array_merge(
165 'page' => [
'INNER JOIN', [
'page_id = rev_page' ] ],
173 'tables' => [
'revision',
'user' ],
174 'fields' => array_merge(
183 'user' => [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ],
191 'tables' => [
'revision',
'text' ],
192 'fields' => array_merge(
202 'text' => [
'INNER JOIN', [
'rev_text_id=old_id' ] ],
208 [
'page',
'user',
'text' ],
210 'tables' => [
'revision',
'page',
'user',
'text' ],
211 'fields' => array_merge(
229 'page' => [
'INNER JOIN', [
'page_id = rev_page' ] ],
230 'user' => [
'LEFT JOIN', [
'rev_user != 0',
'user_id = rev_user' ] ],
231 'text' => [
'INNER JOIN', [
'rev_text_id=old_id' ] ],
246 $store->setContentHandlerUseDB( $contentHandlerUseDb );
247 $this->assertEquals( $expected, $store->getQueryInfo(
$options ) );
275 $store->setContentHandlerUseDB(
true );
281 'fields' => array_merge(
284 'ar_comment_text' =>
'ar_comment',
285 'ar_comment_data' =>
'NULL',
286 'ar_comment_cid' =>
'NULL',
287 'ar_user_text' =>
'ar_user_text',
288 'ar_user' =>
'ar_user',
289 'ar_actor' =>
'NULL',
296 $store->getArchiveQueryInfo()
308 $store->setContentHandlerUseDB(
false );
314 'fields' => array_merge(
317 'ar_comment_text' =>
'ar_comment',
318 'ar_comment_data' =>
'NULL',
319 'ar_comment_cid' =>
'NULL',
320 'ar_user_text' =>
'ar_user_text',
321 'ar_user' =>
'ar_user',
322 'ar_actor' =>
'NULL',
327 $store->getArchiveQueryInfo()
334 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
338 $mockLoadBalancer->expects( $this->atLeastOnce() )
339 ->method(
'getConnection' )
343 $db->expects( $this->at( 0 ) )
344 ->method(
'selectRow' )
350 ->willReturn( (
object)[
351 'page_namespace' =>
'1',
352 'page_title' =>
'Food',
356 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
358 $this->assertSame( 1, $title->getNamespace() );
359 $this->assertSame(
'Food', $title->getDBkey() );
365 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
370 $mockLoadBalancer->expects( $this->exactly( 2 ) )
371 ->method(
'getConnection' )
374 $mockLoadBalancer->expects( $this->atLeastOnce() )
375 ->method(
'getConnectionRef' )
379 $db->expects( $this->at( 0 ) )
380 ->method(
'selectRow' )
386 ->willReturn(
false );
389 $db->expects( $this->at( 1 ) )
390 ->method(
'selectRow' )
392 [
'revision',
'page' ],
396 ->willReturn(
false );
399 $db->expects( $this->at( 2 ) )
400 ->method(
'selectRow' )
406 ->willReturn( (
object)[
407 'page_namespace' =>
'2',
408 'page_title' =>
'Foodey',
412 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
414 $this->assertSame( 2, $title->getNamespace() );
415 $this->assertSame(
'Foodey', $title->getDBkey() );
421 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
425 $mockLoadBalancer->expects( $this->atLeastOnce() )
426 ->method(
'getConnection' )
429 $mockLoadBalancer->expects( $this->atLeastOnce() )
430 ->method(
'getConnectionRef' )
434 $db->expects( $this->at( 0 ) )
435 ->method(
'selectRow' )
441 ->willReturn(
false );
444 $db->expects( $this->at( 1 ) )
445 ->method(
'selectRow' )
447 [
'revision',
'page' ],
451 ->willReturn( (
object)[
452 'page_namespace' =>
'1',
453 'page_title' =>
'Food2',
457 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
459 $this->assertSame( 1, $title->getNamespace() );
460 $this->assertSame(
'Food2', $title->getDBkey() );
466 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
471 $mockLoadBalancer->expects( $this->exactly( 2 ) )
472 ->method(
'getConnection' )
475 $mockLoadBalancer->expects( $this->atLeastOnce() )
476 ->method(
'getConnectionRef' )
480 $db->expects( $this->at( 0 ) )
481 ->method(
'selectRow' )
487 ->willReturn(
false );
490 $db->expects( $this->at( 1 ) )
491 ->method(
'selectRow' )
493 [
'revision',
'page' ],
497 ->willReturn(
false );
500 $db->expects( $this->at( 2 ) )
501 ->method(
'selectRow' )
507 ->willReturn(
false );
510 $db->expects( $this->at( 3 ) )
511 ->method(
'selectRow' )
513 [
'revision',
'page' ],
517 ->willReturn( (
object)[
518 'page_namespace' =>
'2',
519 'page_title' =>
'Foodey',
523 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
525 $this->assertSame( 2, $title->getNamespace() );
526 $this->assertSame(
'Foodey', $title->getDBkey() );
535 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
543 foreach ( [
'getConnection',
'getConnectionRef' ] as $method ) {
544 $mockLoadBalancer->expects( $this->exactly( 2 ) )
546 ->willReturnCallback(
function ( $masterOrReplica ) use (
$db ) {
547 static $callCounter = 0;
550 if ( $callCounter === 1 ) {
551 $this->assertSame(
DB_REPLICA, $masterOrReplica );
552 } elseif ( $callCounter === 2 ) {
553 $this->assertSame(
DB_MASTER, $masterOrReplica );
559 foreach ( [ 0, 2 ] as $counter ) {
560 $db->expects( $this->at( $counter ) )
561 ->method(
'selectRow' )
567 ->willReturn(
false );
570 foreach ( [ 1, 3 ] as $counter ) {
571 $db->expects( $this->at( $counter ) )
572 ->method(
'selectRow' )
574 [
'revision',
'page' ],
578 ->willReturn(
false );
583 $this->setExpectedException( RevisionAccessException::class );
584 $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
588 yield
'windows-1252, old_flags is empty' => [
593 'old_text' =>
"S\xF6me Content",
598 yield
'windows-1252, old_flags is null' => [
603 'old_text' =>
"S\xF6me Content",
619 $blobStore->setLegacyEncoding( $encoding, Language::factory( $locale ) );
623 $record = $store->newRevisionFromRow(
626 Title::newFromText( __METHOD__ .
'-UTPage' )
629 $this->assertSame( $text, $record->getContent(
'main' )->serialize() );
638 'old_flags' =>
'utf-8',
639 'old_text' =>
'Söme Content',
645 $blobStore->setLegacyEncoding(
'windows-1252', Language::factory(
'en' ) );
649 $record = $store->newRevisionFromRow(
652 Title::newFromText( __METHOD__ .
'-UTPage' )
654 $this->assertSame(
'Söme Content', $record->getContent(
'main' )->serialize() );
662 'rev_timestamp' =>
'20110101000000',
663 'rev_user_text' =>
'Tester',
665 'rev_minor_edit' => 0,
668 'rev_parent_id' => 0,
669 'rev_sha1' =>
'deadbeef',
670 'rev_comment_text' =>
'Testing',
671 'rev_comment_data' =>
'{}',
672 'rev_comment_cid' => 111,
675 'page_namespace' => 0,
676 'page_title' =>
'TEST',
679 'page_is_redirect' => 0,
681 'user_name' =>
'Tester',
683 'old_text' =>
'Hello World',
684 'old_flags' =>
'utf-8',
wfGetLB( $wiki=false)
Get a load balancer object.
Simple store for keeping values in an associative array for the current process.
Internationalisation code.
Represents a title within MediaWiki.
Multi-datacenter aware caching interface.
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
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 & $options
const CONTENT_FORMAT_TEXT