24 $db->expects( $this->exactly( count( $updates ) ) )
27 $writer->write( $updates );
33 'primaryKey' => [
'event_id' => $i++ ],
34 'changes' => $changes,
42 return [
'id_field' => ++$i ];
49 $this->assertEquals(
$response[$pos],
$rows,
"Testing row in position $pos" );
53 $this->assertEquals( count(
$response ) - 1, $pos );
59 'some_col' =>
'dvorak',
60 'other_col' =>
'samurai',
65 'Must return single column pk when requested',
71 'Must return multiple column pks when requested',
72 [
'id_field' => 42,
'other_col' =>
'samurai' ],
84 $this->assertEquals( $expected, $reader->extractPrimaryKeys( (
object)$row ), $message );
91 'Must merge primary keys into select conditions',
101 'Must not merge primary keys into the all columns selector',
111 'Must not duplicate primary keys into column selector',
114 [ 0 =>
'foo', 1 =>
'bar', 3 =>
'baz' ],
130 $db->expects( $this->once() )
133 ->with(
'some_table', $columns )
134 ->will( $this->returnValue(
new ArrayIterator( [] ) ) );
137 $reader->setFetchColumns( $fetchColumns );
146 "With single primary key must generate id > 'value'",
148 [
"( id_field > '3' )" ],
154 'With multiple primary keys the first conditions ' .
155 'must use >= and the final condition must use >',
157 [
"( id_field = '3' AND foo > '103' ) OR ( id_field > '3' )" ],
159 [
'id_field',
'foo' ],
172 $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3
174 $results = $this->
genSelectResult( $batchSize, $batchSize * 3,
function () {
175 static $i = 0, $j = 100, $k = 1000;
176 return [
'id_field' => ++$i,
'foo' => ++$j,
'bar' => ++$k ];
180 $conditions = [
'bar' => 42,
'baz' =>
'hai' ];
182 $reader->addConditions( $conditions );
184 $buildConditions =
new ReflectionMethod( $reader,
'buildConditions' );
185 $buildConditions->setAccessible(
true );
188 $this->assertEquals( $conditions, $buildConditions->invoke( $reader ),
189 'First iteration must return only the conditions passed in addConditions' );
194 $conditions + $expectedSecondIteration,
195 $buildConditions->invoke( $reader ),
201 $db = $this->
mockDb( [
'select',
'addQuotes' ] );
202 $db->expects( $this->any() )
205 $db->expects( $this->any() )
206 ->method(
'addQuotes' )
207 ->will( $this->returnCallback(
function (
$value ) {
216 foreach ( $results
as $rows ) {
218 $retvals[] = $this->returnValue(
new ArrayIterator(
$rows ) );
221 return call_user_func_array( [ $this,
'onConsecutiveCalls' ], $retvals );
226 for ( $i = 0; $i < $numRows; $i += $batchSize ) {
228 for ( $j = 0; $j < $batchSize && $i + $j < $numRows; $j++ ) {
229 $rows [] = (
object)call_user_func( $rowGenerator );
237 protected function mockDb( $methods = [] ) {
240 $databaseMysql = $this->getMockBuilder(
Wikimedia\Rdbms\DatabaseMysqli::class )
241 ->disableOriginalConstructor()
242 ->setMethods( array_merge( [
'isOpen',
'getApproximateLagStatus' ], $methods ) )
244 $databaseMysql->expects( $this->any() )
246 ->will( $this->returnValue(
true ) );
247 $databaseMysql->expects( $this->any() )
248 ->method(
'getApproximateLagStatus' )
249 ->will( $this->returnValue( [
'lag' => 0,
'since' => 0 ] ) );
250 return $databaseMysql;
Tests for BatchRowUpdate and its components.
consecutivelyReturnFromSelect(array $results)
testReaderSelectConditionsMultiplePrimaryKeys( $message, $expectedSecondIteration, $primaryKeys, $batchSize=3)
Slightly hackish to use reflection, but asserting different parameters to consecutive calls of Databa...
static provider_readerSetFetchColumns()
genSelectResult( $batchSize, $numRows, $rowGenerator)
static provider_readerGetPrimaryKey()
testWriterBasicFunctionality()
static mockUpdate(array $changes)
static provider_readerSelectConditions()
testReaderGetPrimaryKey( $message, array $expected, array $row)
provider_readerGetPrimaryKey
mockDbConsecutiveSelect(array $retvals)
testReaderSetFetchColumns( $message, array $columns, array $primaryKeys, array $fetchColumns)
provider_readerSetFetchColumns
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
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
this hook is for auditing only $response
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))