MediaWiki  1.32.0
DatabaseSqliteTest.php
Go to the documentation of this file.
1 <?php
2 
7 
9  public static function newInstance( array $p = [] ) {
10  $p['dbFilePath'] = ':memory:';
11  $p['schema'] = false;
12 
13  return Database::factory( 'SqliteMock', $p );
14  }
15 
16  function query( $sql, $fname = '', $tempIgnore = false ) {
17  return true;
18  }
19 
23  public function replaceVars( $s ) {
24  return parent::replaceVars( $s );
25  }
26 }
27 
35  protected $db;
36 
37  protected function setUp() {
38  parent::setUp();
39 
40  if ( !Sqlite::isPresent() ) {
41  $this->markTestSkipped( 'No SQLite support detected' );
42  }
43  $this->db = DatabaseSqliteMock::newInstance();
44  if ( version_compare( $this->db->getServerVersion(), '3.6.0', '<' ) ) {
45  $this->markTestSkipped( "SQLite at least 3.6 required, {$this->db->getServerVersion()} found" );
46  }
47  }
48 
49  private function replaceVars( $sql ) {
50  // normalize spacing to hide implementation details
51  return preg_replace( '/\s+/', ' ', $this->db->replaceVars( $sql ) );
52  }
53 
54  private function assertResultIs( $expected, $res ) {
55  $this->assertNotNull( $res );
56  $i = 0;
57  foreach ( $res as $row ) {
58  foreach ( $expected[$i] as $key => $value ) {
59  $this->assertTrue( isset( $row->$key ) );
60  $this->assertEquals( $value, $row->$key );
61  }
62  $i++;
63  }
64  $this->assertEquals( count( $expected ), $i, 'Unexpected number of rows' );
65  }
66 
67  public static function provideAddQuotes() {
68  return [
69  [ // #0: empty
70  '', "''"
71  ],
72  [ // #1: simple
73  'foo bar', "'foo bar'"
74  ],
75  [ // #2: including quote
76  'foo\'bar', "'foo''bar'"
77  ],
78  // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
79  [
80  "x\0y",
81  "x'780079'",
82  ],
83  [ // #4: blob object (must be represented as hex)
84  new Blob( "hello" ),
85  "x'68656c6c6f'",
86  ],
87  [ // #5: null
88  null,
89  "''",
90  ],
91  ];
92  }
93 
98  public function testAddQuotes( $value, $expected ) {
99  // check quoting
100  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
101  $this->assertEquals( $expected, $db->addQuotes( $value ), 'string not quoted as expected' );
102 
103  // ok, quoting works as expected, now try a round trip.
104  $re = $db->query( 'select ' . $db->addQuotes( $value ) );
105 
106  $this->assertTrue( $re !== false, 'query failed' );
107 
108  $row = $re->fetchRow();
109  if ( $row ) {
110  if ( $value instanceof Blob ) {
111  $value = $value->fetch();
112  }
113 
114  $this->assertEquals( $value, $row[0], 'string mangled by the database' );
115  } else {
116  $this->fail( 'query returned no result' );
117  }
118  }
119 
123  public function testReplaceVars() {
124  $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
125 
126  $this->assertEquals(
127  "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
128  . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
129  $this->replaceVars(
130  "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, "
131  . "foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', "
132  . "foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;"
133  )
134  );
135 
136  $this->assertEquals(
137  "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
138  $this->replaceVars(
139  "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );"
140  )
141  );
142 
143  $this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
144  $this->replaceVars( "CREATE TABLE foo ( foo_binary1 binary(16), foo_binary2 varbinary(32) );" )
145  );
146 
147  $this->assertEquals( "CREATE TABLE text ( text_foo TEXT );",
148  $this->replaceVars( "CREATE TABLE text ( text_foo tinytext );" ),
149  'Table name changed'
150  );
151 
152  $this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
153  $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY NOT NULL AUTO_INCREMENT );" )
154  );
155  $this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
156  $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY AUTO_INCREMENT NOT NULL );" )
157  );
158 
159  $this->assertEquals( "CREATE TABLE enums( enum1 TEXT, myenum TEXT)",
160  $this->replaceVars( "CREATE TABLE enums( enum1 ENUM('A', 'B'), myenum ENUM ('X', 'Y'))" )
161  );
162 
163  $this->assertEquals( "ALTER TABLE foo ADD COLUMN foo_bar INTEGER DEFAULT 42",
164  $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" )
165  );
166 
167  $this->assertEquals( "DROP INDEX foo",
168  $this->replaceVars( "DROP INDEX /*i*/foo ON /*_*/bar" )
169  );
170 
171  $this->assertEquals( "DROP INDEX foo -- dropping index",
172  $this->replaceVars( "DROP INDEX /*i*/foo ON /*_*/bar -- dropping index" )
173  );
174  $this->assertEquals( "INSERT OR IGNORE INTO foo VALUES ('bar')",
175  $this->replaceVars( "INSERT OR IGNORE INTO foo VALUES ('bar')" )
176  );
177  }
178 
182  public function testTableName() {
183  // @todo Moar!
184  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
185  $this->assertEquals( 'foo', $db->tableName( 'foo' ) );
186  $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) );
187  $db->tablePrefix( 'foo' );
188  $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) );
189  $this->assertEquals( 'foobar', $db->tableName( 'bar' ) );
190  }
191 
195  public function testDuplicateTableStructure() {
196  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
197  $db->query( 'CREATE TABLE foo(foo, barfoo)' );
198  $db->query( 'CREATE INDEX index1 ON foo(foo)' );
199  $db->query( 'CREATE UNIQUE INDEX index2 ON foo(barfoo)' );
200 
201  $db->duplicateTableStructure( 'foo', 'bar' );
202  $this->assertEquals( 'CREATE TABLE "bar"(foo, barfoo)',
203  $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'bar' ] ),
204  'Normal table duplication'
205  );
206  $indexList = $db->query( 'PRAGMA INDEX_LIST("bar")' );
207  $index = $indexList->next();
208  $this->assertEquals( 'bar_index1', $index->name );
209  $this->assertEquals( '0', $index->unique );
210  $index = $indexList->next();
211  $this->assertEquals( 'bar_index2', $index->name );
212  $this->assertEquals( '1', $index->unique );
213 
214  $db->duplicateTableStructure( 'foo', 'baz', true );
215  $this->assertEquals( 'CREATE TABLE "baz"(foo, barfoo)',
216  $db->selectField( 'sqlite_temp_master', 'sql', [ 'name' => 'baz' ] ),
217  'Creation of temporary duplicate'
218  );
219  $indexList = $db->query( 'PRAGMA INDEX_LIST("baz")' );
220  $index = $indexList->next();
221  $this->assertEquals( 'baz_index1', $index->name );
222  $this->assertEquals( '0', $index->unique );
223  $index = $indexList->next();
224  $this->assertEquals( 'baz_index2', $index->name );
225  $this->assertEquals( '1', $index->unique );
226  $this->assertEquals( 0,
227  $db->selectField( 'sqlite_master', 'COUNT(*)', [ 'name' => 'baz' ] ),
228  'Create a temporary duplicate only'
229  );
230  }
231 
236  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
237  if ( $db->getFulltextSearchModule() != 'FTS3' ) {
238  $this->markTestSkipped( 'FTS3 not supported, cannot create virtual tables' );
239  }
240  $db->query( 'CREATE VIRTUAL TABLE "foo" USING FTS3(foobar)' );
241 
242  $db->duplicateTableStructure( 'foo', 'bar' );
243  $this->assertEquals( 'CREATE VIRTUAL TABLE "bar" USING FTS3(foobar)',
244  $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'bar' ] ),
245  'Duplication of virtual tables'
246  );
247 
248  $db->duplicateTableStructure( 'foo', 'baz', true );
249  $this->assertEquals( 'CREATE VIRTUAL TABLE "baz" USING FTS3(foobar)',
250  $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'baz' ] ),
251  "Can't create temporary virtual tables, should fall back to non-temporary duplication"
252  );
253  }
254 
258  public function testDeleteJoin() {
259  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
260  $db->query( 'CREATE TABLE a (a_1)', __METHOD__ );
261  $db->query( 'CREATE TABLE b (b_1, b_2)', __METHOD__ );
262  $db->insert( 'a', [
263  [ 'a_1' => 1 ],
264  [ 'a_1' => 2 ],
265  [ 'a_1' => 3 ],
266  ],
267  __METHOD__
268  );
269  $db->insert( 'b', [
270  [ 'b_1' => 2, 'b_2' => 'a' ],
271  [ 'b_1' => 3, 'b_2' => 'b' ],
272  ],
273  __METHOD__
274  );
275  $db->deleteJoin( 'a', 'b', 'a_1', 'b_1', [ 'b_2' => 'a' ], __METHOD__ );
276  $res = $db->query( "SELECT * FROM a", __METHOD__ );
277  $this->assertResultIs( [
278  [ 'a_1' => 1 ],
279  [ 'a_1' => 3 ],
280  ],
281  $res
282  );
283  }
284 
288  public function testEntireSchema() {
289  global $IP;
290 
291  $result = Sqlite::checkSqlSyntax( "$IP/maintenance/tables.sql" );
292  if ( $result !== true ) {
293  $this->fail( $result );
294  }
295  $this->assertTrue( true ); // avoid test being marked as incomplete due to lack of assertions
296  }
297 
303  public function testUpgrades() {
304  global $IP, $wgVersion, $wgProfiler;
305 
306  // Versions tested
307  $versions = [
308  // '1.13', disabled for now, was totally screwed up
309  // SQLite wasn't included in 1.14
310  '1.15',
311  '1.16',
312  '1.17',
313  '1.18',
314  '1.19',
315  '1.20',
316  '1.21',
317  '1.22',
318  '1.23',
319  ];
320 
321  // Mismatches for these columns we can safely ignore
322  $ignoredColumns = [
323  'user_newtalk.user_last_timestamp', // r84185
324  ];
325 
326  $currentDB = DatabaseSqlite::newStandaloneInstance( ':memory:' );
327  $currentDB->sourceFile( "$IP/maintenance/tables.sql" );
328 
329  $profileToDb = false;
330  if ( isset( $wgProfiler['output'] ) ) {
331  $out = $wgProfiler['output'];
332  if ( $out === 'db' ) {
333  $profileToDb = true;
334  } elseif ( is_array( $out ) && in_array( 'db', $out ) ) {
335  $profileToDb = true;
336  }
337  }
338 
339  if ( $profileToDb ) {
340  $currentDB->sourceFile( "$IP/maintenance/sqlite/archives/patch-profiling.sql" );
341  }
342  $currentTables = $this->getTables( $currentDB );
343  sort( $currentTables );
344 
345  foreach ( $versions as $version ) {
346  $versions = "upgrading from $version to $wgVersion";
347  $db = $this->prepareTestDB( $version );
348  $tables = $this->getTables( $db );
349  $this->assertEquals( $currentTables, $tables, "Different tables $versions" );
350  foreach ( $tables as $table ) {
351  $currentCols = $this->getColumns( $currentDB, $table );
352  $cols = $this->getColumns( $db, $table );
353  $this->assertEquals(
354  array_keys( $currentCols ),
355  array_keys( $cols ),
356  "Mismatching columns for table \"$table\" $versions"
357  );
358  foreach ( $currentCols as $name => $column ) {
359  $fullName = "$table.$name";
360  $this->assertEquals(
361  (bool)$column->pk,
362  (bool)$cols[$name]->pk,
363  "PRIMARY KEY status does not match for column $fullName $versions"
364  );
365  if ( !in_array( $fullName, $ignoredColumns ) ) {
366  $this->assertEquals(
367  (bool)$column->notnull,
368  (bool)$cols[$name]->notnull,
369  "NOT NULL status does not match for column $fullName $versions"
370  );
371  $this->assertEquals(
372  $column->dflt_value,
373  $cols[$name]->dflt_value,
374  "Default values does not match for column $fullName $versions"
375  );
376  }
377  }
378  $currentIndexes = $this->getIndexes( $currentDB, $table );
379  $indexes = $this->getIndexes( $db, $table );
380  $this->assertEquals(
381  array_keys( $currentIndexes ),
382  array_keys( $indexes ),
383  "mismatching indexes for table \"$table\" $versions"
384  );
385  }
386  $db->close();
387  }
388  }
389 
393  public function testInsertIdType() {
394  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
395 
396  $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ );
397  $this->assertInstanceOf( ResultWrapper::class, $databaseCreation, "Database creation" );
398 
399  $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ );
400  $this->assertTrue( $insertion, "Insertion worked" );
401 
402  $this->assertInternalType( 'integer', $db->insertId(), "Actual typecheck" );
403  $this->assertTrue( $db->close(), "closing database" );
404  }
405 
406  private function prepareTestDB( $version ) {
407  static $maint = null;
408  if ( $maint === null ) {
409  $maint = new FakeMaintenance();
410  $maint->loadParamsAndArgs( null, [ 'quiet' => 1 ] );
411  }
412 
413  global $IP;
414  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
415  $db->sourceFile( "$IP/tests/phpunit/data/db/sqlite/tables-$version.sql" );
416  $updater = DatabaseUpdater::newForDB( $db, false, $maint );
417  $updater->doUpdates( [ 'core' ] );
418 
419  return $db;
420  }
421 
422  private function getTables( $db ) {
423  $list = array_flip( $db->listTables() );
424  $excluded = [
425  'external_user', // removed from core in 1.22
426  'math', // moved out of core in 1.18
427  'trackbacks', // removed from core in 1.19
428  'searchindex',
429  'searchindex_content',
430  'searchindex_segments',
431  'searchindex_segdir',
432  // FTS4 ready!!1
433  'searchindex_docsize',
434  'searchindex_stat',
435  ];
436  foreach ( $excluded as $t ) {
437  unset( $list[$t] );
438  }
439  $list = array_flip( $list );
440  sort( $list );
441 
442  return $list;
443  }
444 
445  private function getColumns( $db, $table ) {
446  $cols = [];
447  $res = $db->query( "PRAGMA table_info($table)" );
448  $this->assertNotNull( $res );
449  foreach ( $res as $col ) {
450  $cols[$col->name] = $col;
451  }
452  ksort( $cols );
453 
454  return $cols;
455  }
456 
457  private function getIndexes( $db, $table ) {
458  $indexes = [];
459  $res = $db->query( "PRAGMA index_list($table)" );
460  $this->assertNotNull( $res );
461  foreach ( $res as $index ) {
462  $res2 = $db->query( "PRAGMA index_info({$index->name})" );
463  $this->assertNotNull( $res2 );
464  $index->columns = [];
465  foreach ( $res2 as $col ) {
466  $index->columns[] = $col;
467  }
468  $indexes[$index->name] = $index;
469  }
470  ksort( $indexes );
471 
472  return $indexes;
473  }
474 
475  public function testCaseInsensitiveLike() {
476  // TODO: Test this for all databases
477  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
478  $res = $db->query( 'SELECT "a" LIKE "A" AS a' );
479  $row = $res->fetchRow();
480  $this->assertFalse( (bool)$row['a'] );
481  }
482 
486  public function testNumFields() {
487  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
488 
489  $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ );
490  $this->assertInstanceOf( ResultWrapper::class, $databaseCreation, "Failed to create table a" );
491  $res = $db->select( 'a', '*' );
492  $this->assertEquals( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" );
493  $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ );
494  $this->assertTrue( $insertion, "Insertion failed" );
495  $res = $db->select( 'a', '*' );
496  $this->assertEquals( 1, $db->numFields( $res ), "wrong number of fields" );
497 
498  $this->assertTrue( $db->close(), "closing database" );
499  }
500 
504  public function testToString() {
505  $db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
506 
507  $toString = (string)$db;
508 
509  $this->assertContains( 'SQLite ', $toString );
510  }
511 
515  public function testsAttributes() {
516  $attributes = Database::attributesFromType( 'sqlite' );
517  $this->assertTrue( $attributes[Database::ATTR_DB_LEVEL_LOCKING] );
518  }
519 }
DatabaseSqliteTest\testAddQuotes
testAddQuotes( $value, $expected)
provideAddQuotes() DatabaseSqlite::addQuotes
Definition: DatabaseSqliteTest.php:98
Wikimedia\Rdbms\Database\tablePrefix
tablePrefix( $prefix=null)
Get/set the table prefix.
Definition: Database.php:595
Wikimedia\Rdbms\DatabaseSqlite\addQuotes
addQuotes( $s)
Definition: DatabaseSqlite.php:825
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:48
DatabaseSqliteTest\testCaseInsensitiveLike
testCaseInsensitiveLike()
Definition: DatabaseSqliteTest.php:475
DatabaseSqliteTest\assertResultIs
assertResultIs( $expected, $res)
Definition: DatabaseSqliteTest.php:54
DatabaseSqliteTest\testTableName
testTableName()
DatabaseSqlite::tableName.
Definition: DatabaseSqliteTest.php:182
Wikimedia\Rdbms\DatabaseSqlite
Definition: DatabaseSqlite.php:37
Wikimedia\Rdbms\DatabaseSqlite\listTables
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
Definition: DatabaseSqlite.php:1044
DatabaseSqliteTest\$db
DatabaseSqliteMock $db
Definition: DatabaseSqliteTest.php:35
Wikimedia\Rdbms\Database\deleteJoin
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Definition: Database.php:2904
captcha-old.count
count
Definition: captcha-old.py:249
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:2034
$wgVersion
$wgVersion
MediaWiki version number.
Definition: DefaultSettings.php:74
DatabaseSqliteMock\query
query( $sql, $fname='', $tempIgnore=false)
Run an SQL query and return the result.
Definition: DatabaseSqliteTest.php:16
DatabaseSqliteTest\testEntireSchema
testEntireSchema()
@coversNothing
Definition: DatabaseSqliteTest.php:288
$tables
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:1018
DatabaseSqliteTest\getTables
getTables( $db)
Definition: DatabaseSqliteTest.php:422
$s
$s
Definition: mergeMessageFileList.php:187
$res
$res
Definition: database.txt:21
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
DatabaseSqliteTest
sqlite Database medium
Definition: DatabaseSqliteTest.php:33
DatabaseSqliteTest\testReplaceVars
testReplaceVars()
DatabaseSqlite::replaceVars.
Definition: DatabaseSqliteTest.php:123
php
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
DatabaseSqliteTest\testToString
testToString()
\Wikimedia\Rdbms\DatabaseSqlite::__toString
Definition: DatabaseSqliteTest.php:504
DatabaseSqliteTest\setUp
setUp()
Definition: DatabaseSqliteTest.php:37
DatabaseSqliteMock
Definition: DatabaseSqliteTest.php:8
$wgProfiler
$wgProfiler
Profiler configuration.
Definition: DefaultSettings.php:6416
DatabaseSqliteTest\testDeleteJoin
testDeleteJoin()
DatabaseSqlite::deleteJoin.
Definition: DatabaseSqliteTest.php:258
MediaWikiTestCase
Definition: MediaWikiTestCase.php:16
$IP
$IP
Definition: update.php:3
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
DatabaseSqliteTest\provideAddQuotes
static provideAddQuotes()
Definition: DatabaseSqliteTest.php:67
FakeMaintenance
Fake maintenance wrapper, mostly used for the web installer/updater.
Definition: Maintenance.php:1668
DatabaseSqliteTest\getIndexes
getIndexes( $db, $table)
Definition: DatabaseSqliteTest.php:457
array
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))
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
Sqlite\isPresent
static isPresent()
Checks whether PHP has SQLite support.
Definition: sqlite.inc:38
DatabaseSqliteTest\testDuplicateTableStructureVirtual
testDuplicateTableStructureVirtual()
DatabaseSqlite::duplicateTableStructure.
Definition: DatabaseSqliteTest.php:235
DatabaseSqliteMock\newInstance
static newInstance(array $p=[])
Definition: DatabaseSqliteTest.php:9
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:121
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
DatabaseSqliteTest\testInsertIdType
testInsertIdType()
DatabaseSqlite::insertId.
Definition: DatabaseSqliteTest.php:393
$value
$value
Definition: styleTest.css.php:49
DatabaseSqliteTest\getColumns
getColumns( $db, $table)
Definition: DatabaseSqliteTest.php:445
DatabaseSqliteTest\testUpgrades
testUpgrades()
Runs upgrades of older databases and compares results with current schema.
Definition: DatabaseSqliteTest.php:303
DatabaseSqliteTest\testsAttributes
testsAttributes()
\Wikimedia\Rdbms\DatabaseSqlite::getAttributes()
Definition: DatabaseSqliteTest.php:515
Wikimedia\Rdbms\Database\selectField
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
Definition: Database.php:1505
Wikimedia\Rdbms\DatabaseSqlite\insert
insert( $table, $a, $fname=__METHOD__, $options=[])
Based on generic method (parent) with some prior SQLite-sepcific adjustments.
Definition: DatabaseSqlite.php:644
DatabaseUpdater\newForDB
static newForDB(Database $db, $shared=false, Maintenance $maintenance=null)
Definition: DatabaseUpdater.php:189
Wikimedia\Rdbms\Database\close
close()
Close the database connection.
Definition: Database.php:917
Wikimedia\Rdbms\DatabaseSqlite\getFulltextSearchModule
static getFulltextSearchModule()
Returns version of currently supported SQLite fulltext search module or false if none present.
Definition: DatabaseSqlite.php:274
Sqlite\checkSqlSyntax
static checkSqlSyntax( $files)
Checks given files for correctness of SQL syntax.
Definition: sqlite.inc:50
Wikimedia\Rdbms\DatabaseSqlite\insertId
insertId()
This must be called after nextSequenceVal.
Definition: DatabaseSqlite.php:465
DatabaseSqliteMock\replaceVars
replaceVars( $s)
Override parent visibility to public.
Definition: DatabaseSqliteTest.php:23
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 as
Definition: distributors.txt:9
DatabaseSqliteTest\prepareTestDB
prepareTestDB( $version)
Definition: DatabaseSqliteTest.php:406
$updater
$page->newPageUpdater($user) $updater
Definition: pageupdater.txt:63
Wikimedia\Rdbms\Database\select
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
Definition: Database.php:1688
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
$t
$t
Definition: testCompression.php:69
DatabaseSqliteTest\testDuplicateTableStructure
testDuplicateTableStructure()
DatabaseSqlite::duplicateTableStructure.
Definition: DatabaseSqliteTest.php:195
DatabaseSqliteTest\testNumFields
testNumFields()
DatabaseSqlite::numFields.
Definition: DatabaseSqliteTest.php:486
Wikimedia\Rdbms\Database\sourceFile
sourceFile( $filename, callable $lineCallback=null, callable $resultCallback=null, $fname=false, callable $inputCallback=null)
Read and execute SQL commands from a file.
Definition: Database.php:4266
DatabaseSqliteTest\replaceVars
replaceVars( $sql)
Definition: DatabaseSqliteTest.php:49
Wikimedia\Rdbms\DatabaseSqlite\duplicateTableStructure
duplicateTableStructure( $oldName, $newName, $temporary=false, $fname=__METHOD__)
Definition: DatabaseSqlite.php:979
Wikimedia\Rdbms\DatabaseSqlite\numFields
numFields( $res)
Definition: DatabaseSqlite.php:417
Wikimedia\Rdbms\DatabaseSqlite\tableName
tableName( $name, $format='quoted')
Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks.
Definition: DatabaseSqlite.php:451
Wikimedia\Rdbms\Blob
Definition: Blob.php:5
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:813