36 $this->cliMode =
true;
37 $this->connLogger = new \Psr\Log\NullLogger();
38 $this->queryLogger = new \Psr\Log\NullLogger();
39 $this->errorLogger =
function ( Exception
$e ) {
40 wfWarn( get_class(
$e ) .
": {$e->getMessage()}" );
113 $this->assertEquals( $expected, $quoted );
139 [
"`'`",
"'" ], # single quote
140 [
'`"`',
'"' ], #
double quote
141 [
'````',
'`' ], # backtick
142 [
'`’`',
'’' ], # apostrophe (look at your encyclopedia)
146 [
'`xyzzy`',
"\0x\0y\0z\0z\0y\0" ],
158 [
'`メインページ`',
'メインページ' ],
159 [
'`Басты_бет`',
'Басты_бет' ],
162 [
'`Alix`',
'Alix' ], #
while( ! $recovered ) { sleep(); }
163 [
'`Backtick: ```',
'Backtick: `' ],
164 [
'`This is a test`',
'This is a test' ],
169 return json_decode(
'"' . $str .
'"' );
173 $db = $this->getMockBuilder(
'DatabaseMysql' )
174 ->disableOriginalConstructor()
175 ->setMethods( [
'fetchRow',
'query' ] )
178 $db->method(
'query' )
181 (
object)[
'Tables_in_' =>
'view1' ],
182 (
object)[
'Tables_in_' =>
'view2' ],
183 (
object)[
'Tables_in_' =>
'myview' ]
194 $this->assertEquals( [
'view1',
'view2',
'myview' ],
198 $this->assertEquals( [
'view1',
'view2' ],
200 $this->assertEquals( [
'myview' ],
202 $this->assertEquals( [],
204 $this->assertEquals( [
'view1',
'view2',
'myview' ],
215 $this->assertTrue( $higherPos->
hasReached( $lowerPos ) );
216 $this->assertTrue( $higherPos->
hasReached( $higherPos ) );
217 $this->assertTrue( $lowerPos->
hasReached( $lowerPos ) );
218 $this->assertFalse( $lowerPos->
hasReached( $higherPos ) );
220 $this->assertFalse( $lowerPos->
channelsMatch( $higherPos ) );
222 $this->assertFalse( $higherPos->
hasReached( $lowerPos ) );
223 $this->assertFalse( $lowerPos->
hasReached( $higherPos ) );
247 new MySQLMasterPos(
'db1-bin.2',
'1',
'3E11FA47-71CA-11E1-9E33-C80AA9429562:23' ),
248 new MySQLMasterPos(
'db1-bin.2',
'2',
'3E11FA47-71CA-11E1-9E33-C80AA9429562:24' ),
252 new MySQLMasterPos(
'db1-bin.2',
'1',
'3E11FA47-71CA-11E1-9E33-C80AA9429562:99' ),
253 new MySQLMasterPos(
'db1-bin.2',
'2',
'3E11FA47-71CA-11E1-9E33-C80AA9429562:100' ),
257 new MySQLMasterPos(
'db1-bin.2',
'1',
'3E11FA47-71CA-11E1-9E33-C80AA9429562:99' ),
258 new MySQLMasterPos(
'db1-bin.2',
'2',
'1E11FA47-71CA-11E1-9E33-C80AA9429562:100' ),
317 $db = $this->getMockBuilder(
'DatabaseMysql' )
318 ->disableOriginalConstructor()
320 'getLagDetectionMethod',
'getHeartbeatData',
'getMasterServerInfo' ] )
323 $db->method(
'getLagDetectionMethod' )
324 ->willReturn(
'pt-heartbeat' );
326 $db->method(
'getMasterServerInfo' )
327 ->willReturn( [
'serverId' => 172,
'asOf' => time() ] );
330 list( $nowSecFrac, $nowSec ) = explode(
' ', microtime() );
331 $now = (float)$nowSec + (
float)$nowSecFrac;
334 $ptTime = $now - $lag;
335 $ptSec = (int)$ptTime;
336 $ptSecFrac = ( $ptTime - $ptSec );
337 $ptDateTime =
new DateTime(
"@$ptSec" );
338 $ptTimeISO = $ptDateTime->format(
'Y-m-d\TH:i:s' );
339 $ptTimeISO .= ltrim( number_format( $ptSecFrac, 6 ),
'0' );
341 $db->method(
'getHeartbeatData' )
342 ->with( [
'server_id' => 172 ] )
343 ->willReturn( [ $ptTimeISO, $now ] );
348 $this->assertGreaterThan( $lag - .010, $lagEst,
"Correct heatbeat lag" );
349 $this->assertLessThan( $lag + .010, $lagEst,
"Correct heatbeat lag" );
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
testHasReached(MySQLMasterPos $lowerPos, MySQLMasterPos $higherPos, $match)
provideComparePositions
testPtHeartbeat( $lag)
provideLagAmounts
testAddIdentifierQuotes( $expected, $in)
provideDiapers DatabaseMysqlBase::addIdentifierQuotes
provideChannelPositions()
static createUnicodeString( $str)
testChannelsMatch(MySQLMasterPos $pos1, MySQLMasterPos $pos2, $matches)
provideChannelPositions
testListviews()
DatabaseMysqlBase::listViews.
provideDiapers()
Feeds testAddIdentifierQuotes.
provideComparePositions()
Database abstraction object for MySQL.
getLag()
Get replica DB lag.
addIdentifierQuotes( $s)
Quotes an identifier using backticks or "double quotes" depending on the database type.
setLBInfo( $name, $value=null)
Set the LB info array, or a member of it.
listViews( $prefix=null, $fname=__METHOD__)
Lists all the VIEWs in the database.
Fake class around abstract class so we can call concrete methods.
mysqlNumFields( $res)
Get number of fields in result.
mysqlSetCharset( $charset)
Set the character set of the MySQL link.
mysqlFreeResult( $res)
Free result memory.
mysqlFieldType( $res, $n)
Get the type of the specified field in a result.
affectedRows()
Get the number of rows affected by the last write query.
mysqlRealEscapeString( $s)
mysqlConnect( $realServer)
Open a connection to a MySQL server.
doQuery( $sql)
The DBMS-dependent part of query()
lastErrno()
Get the last error number.
mysqlFetchField( $res, $n)
Get column information from a result.
mysqlFetchObject( $res)
Fetch a result row as an object.
mysqlNumRows( $res)
Get number of rows in result.
mysqlFetchArray( $res)
Fetch a result row as an associative and numeric array.
mysqlFieldName( $res, $n)
Get the name of the specified field in a result.
insertId()
Get the inserted value of an auto-increment row.
mysqlError( $conn=null)
Returns the text of the error message from previous MySQL operation.
closeConnection()
Closes underlying database connection.
mysqlDataSeek( $res, $row)
Move internal result pointer.
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
DBMasterPos class for MySQL/MariaDB.
channelsMatch(DBMasterPos $pos)
hasReached(DBMasterPos $pos)
Stub profiler that does nothing.
Helper class that detects high-contention DB queries via profiling calls.
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
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 noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
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