MediaWiki  1.28.1
DatabaseUpdaterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5  public function testSetAppliedUpdates() {
6  $db = new FakeDatabase();
7  $dbu = new FakeDatabaseUpdater( $db );
8  $dbu->setAppliedUpdates( "test", [] );
9  $expected = "updatelist-test-" . time() . "0";
10  $actual = $db->lastInsertData['ul_key'];
11  $this->assertEquals( $expected, $actual, var_export( $db->lastInsertData, true ) );
12  $dbu->setAppliedUpdates( "test", [] );
13  $expected = "updatelist-test-" . time() . "1";
14  $actual = $db->lastInsertData['ul_key'];
15  $this->assertEquals( $expected, $actual, var_export( $db->lastInsertData, true ) );
16  }
17 }
18 
19 class FakeDatabase extends Database {
22 
23  function __construct() {
24  $this->cliMode = true;
25  $this->connLogger = new \Psr\Log\NullLogger();
26  $this->queryLogger = new \Psr\Log\NullLogger();
27  $this->errorLogger = function ( Exception $e ) {
28  wfWarn( get_class( $e ) . ": {$e->getMessage()}" );
29  };
30  $this->currentDomain = DatabaseDomain::newUnspecified();
31  }
32 
33  function clearFlag( $arg, $remember = self::REMEMBER_NOTHING ) {
34  }
35 
36  function setFlag( $arg, $remember = self::REMEMBER_NOTHING ) {
37  }
38 
39  public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
40  $this->lastInsertTable = $table;
41  $this->lastInsertData = $a;
42  }
43 
49  function getType() {
50  // TODO: Implement getType() method.
51  }
52 
63  function open( $server, $user, $password, $dbName ) {
64  // TODO: Implement open() method.
65  }
66 
77  function fetchObject( $res ) {
78  // TODO: Implement fetchObject() method.
79  }
80 
90  function fetchRow( $res ) {
91  // TODO: Implement fetchRow() method.
92  }
93 
100  function numRows( $res ) {
101  // TODO: Implement numRows() method.
102  }
103 
111  function numFields( $res ) {
112  // TODO: Implement numFields() method.
113  }
114 
123  function fieldName( $res, $n ) {
124  // TODO: Implement fieldName() method.
125  }
126 
139  function insertId() {
140  // TODO: Implement insertId() method.
141  }
142 
150  function dataSeek( $res, $row ) {
151  // TODO: Implement dataSeek() method.
152  }
153 
160  function lastErrno() {
161  // TODO: Implement lastErrno() method.
162  }
163 
170  function lastError() {
171  // TODO: Implement lastError() method.
172  }
173 
183  function fieldInfo( $table, $field ) {
184  // TODO: Implement fieldInfo() method.
185  }
186 
194  function indexInfo( $table, $index, $fname = __METHOD__ ) {
195  // TODO: Implement indexInfo() method.
196  }
197 
204  function affectedRows() {
205  // TODO: Implement affectedRows() method.
206  }
207 
214  function strencode( $s ) {
215  // TODO: Implement strencode() method.
216  }
217 
226  function getSoftwareLink() {
227  // TODO: Implement getSoftwareLink() method.
228  }
229 
236  function getServerVersion() {
237  // TODO: Implement getServerVersion() method.
238  }
239 
245  protected function closeConnection() {
246  // TODO: Implement closeConnection() method.
247  }
248 
256  protected function doQuery( $sql ) {
257  // TODO: Implement doQuery() method.
258  }
259 }
260 
262  function __construct( $db ) {
263  $this->db = $db;
264  self::$updateCounter = 0;
265  }
266 
275  protected function getCoreUpdateList() {
276  return [];
277  }
278 
279  public function canUseNewUpdatelog() {
280  return true;
281  }
282 
283  public function setAppliedUpdates( $version, $updates = [] ) {
284  parent::setAppliedUpdates( $version, $updates );
285  }
286 }
indexInfo($table, $index, $fname=__METHOD__)
Get information about an index into an object.
numRows($res)
Get the number of rows in a result object.
insertId()
Get the inserted value of an auto-increment row.
static newUnspecified()
getServerVersion()
A string describing the current software version, like from mysql_get_server_info().
fetchRow($res)
Fetch the next row from the given result object, in associative array form.
setAppliedUpdates($version, $updates=[])
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:2102
clearFlag($arg, $remember=self::REMEMBER_NOTHING)
Clear a flag for this connection.
Class for handling database updates.
fetchObject($res)
Fetch the next row from the given result object, in object form.
fieldInfo($table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
strencode($s)
Wrapper for addslashes()
open($server, $user, $password, $dbName)
Open a connection to the database.
getSoftwareLink()
Returns a wikitext link to the DB's website, e.g., return "[http://www.mysql.com/ MySQL]"; Should at ...
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
doQuery($sql)
The DBMS-dependent part of query()
Database $db
Handle to the database subclass.
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
array $updates
Array of updates to perform on the database.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1046
$res
Definition: database.txt:21
fieldName($res, $n)
Get a field name in a result object.
lastErrno()
Get the last error number.
dataSeek($res, $row)
Change the position of the cursor in a result object.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:242
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:35
insert($table, $a, $fname=__METHOD__, $options=[])
INSERT wrapper, inserts an array into a table.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Definition: Setup.php:36
numFields($res)
Get the number of fields in a result object.
affectedRows()
Get the number of rows affected by the last write query.
Database $db
Primary database.
setFlag($arg, $remember=self::REMEMBER_NOTHING)
Set a flag for this connection.
lastError()
Get a description of the last error.
getCoreUpdateList()
Get an array of updates to perform on the database.
closeConnection()
Closes underlying database connection.