7use InvalidArgumentException;
20use Wikimedia\TestingAccessWrapper;
41 $WANObjectCache =
null
63 return $this->getMockBuilder( LoadBalancer::class )
64 ->disableOriginalConstructor()->getMock();
71 return $this->getMockBuilder( Database::class )
72 ->disableOriginalConstructor()->getMock();
79 return $this->getMockBuilder( SqlBlobStore::class )
80 ->disableOriginalConstructor()->getMock();
87 return $this->getMockBuilder( CommentStore::class )
88 ->disableOriginalConstructor()->getMock();
117 if ( $expectedFail ) {
118 $this->setExpectedException( MWException::class );
128 $nameTables->getContentModels(),
129 $nameTables->getSlotRoles(),
134 $store->setContentHandlerUseDB( $contentHandlerDb );
135 $this->assertSame( $contentHandlerDb, $store->getContentHandlerUseDB() );
141 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
145 $mockLoadBalancer->expects( $this->atLeastOnce() )
146 ->method(
'getConnection' )
150 $db->expects( $this->at( 0 ) )
151 ->method(
'selectRow' )
157 ->willReturn( (
object)[
158 'page_namespace' =>
'1',
159 'page_title' =>
'Food',
163 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
165 $this->assertSame( 1,
$title->getNamespace() );
166 $this->assertSame(
'Food',
$title->getDBkey() );
172 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
177 $mockLoadBalancer->expects( $this->exactly( 2 ) )
178 ->method(
'getConnection' )
181 $mockLoadBalancer->expects( $this->atLeastOnce() )
182 ->method(
'getConnectionRef' )
186 $db->expects( $this->at( 0 ) )
187 ->method(
'selectRow' )
193 ->willReturn(
false );
196 $db->expects( $this->at( 1 ) )
197 ->method(
'selectRow' )
199 [
'revision',
'page' ],
203 ->willReturn(
false );
206 $db->expects( $this->at( 2 ) )
207 ->method(
'selectRow' )
213 ->willReturn( (
object)[
214 'page_namespace' =>
'2',
215 'page_title' =>
'Foodey',
219 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
221 $this->assertSame( 2,
$title->getNamespace() );
222 $this->assertSame(
'Foodey',
$title->getDBkey() );
228 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
232 $mockLoadBalancer->expects( $this->atLeastOnce() )
233 ->method(
'getConnection' )
236 $mockLoadBalancer->expects( $this->atLeastOnce() )
237 ->method(
'getConnectionRef' )
241 $db->expects( $this->at( 0 ) )
242 ->method(
'selectRow' )
248 ->willReturn(
false );
251 $db->expects( $this->at( 1 ) )
252 ->method(
'selectRow' )
254 [
'revision',
'page' ],
258 ->willReturn( (
object)[
259 'page_namespace' =>
'1',
260 'page_title' =>
'Food2',
264 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
266 $this->assertSame( 1,
$title->getNamespace() );
267 $this->assertSame(
'Food2',
$title->getDBkey() );
273 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
278 $mockLoadBalancer->expects( $this->exactly( 2 ) )
279 ->method(
'getConnection' )
282 $mockLoadBalancer->expects( $this->atLeastOnce() )
283 ->method(
'getConnectionRef' )
287 $db->expects( $this->at( 0 ) )
288 ->method(
'selectRow' )
294 ->willReturn(
false );
297 $db->expects( $this->at( 1 ) )
298 ->method(
'selectRow' )
300 [
'revision',
'page' ],
304 ->willReturn(
false );
307 $db->expects( $this->at( 2 ) )
308 ->method(
'selectRow' )
314 ->willReturn(
false );
317 $db->expects( $this->at( 3 ) )
318 ->method(
'selectRow' )
320 [
'revision',
'page' ],
324 ->willReturn( (
object)[
325 'page_namespace' =>
'2',
326 'page_title' =>
'Foodey',
330 $title = $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
332 $this->assertSame( 2,
$title->getNamespace() );
333 $this->assertSame(
'Foodey',
$title->getDBkey() );
342 $this->
setService(
'DBLoadBalancer', $mockLoadBalancer );
350 foreach ( [
'getConnection',
'getConnectionRef' ]
as $method ) {
351 $mockLoadBalancer->expects( $this->exactly( 2 ) )
353 ->willReturnCallback(
function ( $masterOrReplica )
use (
$db ) {
354 static $callCounter = 0;
357 if ( $callCounter === 1 ) {
358 $this->assertSame(
DB_REPLICA, $masterOrReplica );
359 } elseif ( $callCounter === 2 ) {
360 $this->assertSame(
DB_MASTER, $masterOrReplica );
366 foreach ( [ 0, 2 ]
as $counter ) {
367 $db->expects( $this->at( $counter ) )
368 ->method(
'selectRow' )
374 ->willReturn(
false );
377 foreach ( [ 1, 3 ]
as $counter ) {
378 $db->expects( $this->at( $counter ) )
379 ->method(
'selectRow' )
381 [
'revision',
'page' ],
385 ->willReturn(
false );
390 $this->setExpectedException( RevisionAccessException::class );
391 $store->getTitle( 1, 2, RevisionStore::READ_NORMAL );
395 yield
'windows-1252, old_flags is empty' => [
400 'old_text' =>
"S\xF6me Content",
405 yield
'windows-1252, old_flags is null' => [
410 'old_text' =>
"S\xF6me Content",
423 $this->markTestSkipped(
'No longer applicable with MCR schema' );
430 $blobStore->setLegacyEncoding( $encoding, Language::factory( $locale ) );
434 $record = $store->newRevisionFromRow(
437 Title::newFromText( __METHOD__ .
'-UTPage' )
440 $this->assertSame( $text, $record->getContent( SlotRecord::MAIN )->serialize() );
448 $this->markTestSkipped(
'No longer applicable with MCR schema' );
452 'old_flags' =>
'utf-8',
453 'old_text' =>
'Söme Content',
460 $blobStore->setLegacyEncoding(
'windows-1252', Language::factory(
'en' ) );
464 $record = $store->newRevisionFromRow(
467 Title::newFromText( __METHOD__ .
'-UTPage' )
469 $this->assertSame(
'Söme Content', $record->getContent( SlotRecord::MAIN )->serialize() );
476 'rev_timestamp' =>
'20110101000000',
477 'rev_user_text' =>
'Tester',
479 'rev_minor_edit' => 0,
482 'rev_parent_id' => 0,
483 'rev_sha1' =>
'deadbeef',
484 'rev_comment_text' =>
'Testing',
485 'rev_comment_data' =>
'{}',
486 'rev_comment_cid' => 111,
487 'page_namespace' => 0,
488 'page_title' =>
'TEST',
491 'page_is_redirect' => 0,
493 'user_name' =>
'Tester',
502 'old_text' =>
'Hello World',
503 'old_flags' =>
'utf-8',
506 if ( !isset( $row[
'content'] ) && isset( $array[
'old_text'] ) ) {
533 if ( $expectException ) {
534 $this->setExpectedException( InvalidArgumentException::class );
541 $nameTables =
$services->getNameTableStoreFactory();
542 $contentModelStore = $nameTables->getContentModels();
543 $slotRoleStore = $nameTables->getSlotRoles();
549 $nameTables->getContentModels(),
550 $nameTables->getSlotRoles(),
554 if ( !$expectException ) {
555 $store = TestingAccessWrapper::newFromObject( $store );
556 $this->assertSame( $loadBalancer, $store->loadBalancer );
557 $this->assertSame( $blobStore, $store->blobStore );
558 $this->assertSame(
$cache, $store->cache );
559 $this->assertSame( $commentStore, $store->commentStore );
560 $this->assertSame( $contentModelStore, $store->contentModelStore );
561 $this->assertSame( $slotRoleStore, $store->slotRoleStore );
562 $this->assertSame( $migration, $store->mcrMigrationStage );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
int $wgMultiContentRevisionSchemaMigrationStage
RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
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.
Content object for wiki text pages.
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 as
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
const SCHEMA_COMPAT_WRITE_BOTH
const SCHEMA_COMPAT_READ_NEW
const SCHEMA_COMPAT_READ_BOTH
const SCHEMA_COMPAT_WRITE_OLD
const CONTENT_FORMAT_TEXT
const SCHEMA_COMPAT_READ_OLD
const SCHEMA_COMPAT_WRITE_NEW
namespace and then decline to actually register it file or subcat img or subcat $title
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
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 or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
processing should stop and the error should be shown to the user * false
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))