MediaWiki  1.27.2
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 DatabaseBase {
22 
23  function __construct() {
24  }
25 
26  function clearFlag( $arg ) {
27  }
28 
29  function setFlag( $arg ) {
30  }
31 
32  public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
33  $this->lastInsertTable = $table;
34  $this->lastInsertData = $a;
35  }
36 
42  function getType() {
43  // TODO: Implement getType() method.
44  }
45 
56  function open( $server, $user, $password, $dbName ) {
57  // TODO: Implement open() method.
58  }
59 
70  function fetchObject( $res ) {
71  // TODO: Implement fetchObject() method.
72  }
73 
83  function fetchRow( $res ) {
84  // TODO: Implement fetchRow() method.
85  }
86 
93  function numRows( $res ) {
94  // TODO: Implement numRows() method.
95  }
96 
104  function numFields( $res ) {
105  // TODO: Implement numFields() method.
106  }
107 
116  function fieldName( $res, $n ) {
117  // TODO: Implement fieldName() method.
118  }
119 
132  function insertId() {
133  // TODO: Implement insertId() method.
134  }
135 
143  function dataSeek( $res, $row ) {
144  // TODO: Implement dataSeek() method.
145  }
146 
153  function lastErrno() {
154  // TODO: Implement lastErrno() method.
155  }
156 
163  function lastError() {
164  // TODO: Implement lastError() method.
165  }
166 
176  function fieldInfo( $table, $field ) {
177  // TODO: Implement fieldInfo() method.
178  }
179 
187  function indexInfo( $table, $index, $fname = __METHOD__ ) {
188  // TODO: Implement indexInfo() method.
189  }
190 
197  function affectedRows() {
198  // TODO: Implement affectedRows() method.
199  }
200 
207  function strencode( $s ) {
208  // TODO: Implement strencode() method.
209  }
210 
219  function getSoftwareLink() {
220  // TODO: Implement getSoftwareLink() method.
221  }
222 
229  function getServerVersion() {
230  // TODO: Implement getServerVersion() method.
231  }
232 
238  protected function closeConnection() {
239  // TODO: Implement closeConnection() method.
240  }
241 
249  protected function doQuery( $sql ) {
250  // TODO: Implement doQuery() method.
251  }
252 }
253 
255  function __construct( $db ) {
256  $this->db = $db;
257  self::$updateCounter = 0;
258  }
259 
268  protected function getCoreUpdateList() {
269  return [];
270  }
271 
272  public function canUseNewUpdatelog() {
273  return true;
274  }
275 
276  public function setAppliedUpdates( $version, $updates = [] ) {
277  parent::setAppliedUpdates( $version, $updates );
278  }
279 }
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.
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=[])
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()
DatabaseBase $db
Handle to the database subclass.
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:1004
$res
Definition: database.txt:21
fieldName($res, $n)
Get a field name in a result object.
clearFlag($arg)
Clear a flag for this connection.
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
setFlag($arg)
Set a flag for this connection.
Database abstraction object.
Definition: Database.php:32
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:35
numFields($res)
Get the number of fields in a result object.
affectedRows()
Get the number of rows affected by the last write query.
DatabaseBase $db
Primary database.
$version
Definition: parserTests.php:85
lastError()
Get a description of the last error.
getCoreUpdateList()
Get an array of updates to perform on the database.
closeConnection()
Closes underlying database connection.