MediaWiki REL1_28
DatabaseSqliteTest.php
Go to the documentation of this file.
1<?php
2
4 private $lastQuery;
5
6 public static function newInstance( array $p = [] ) {
7 $p['dbFilePath'] = ':memory:';
8 $p['schema'] = false;
9
10 return Database::factory( 'SqliteMock', $p );
11 }
12
13 function query( $sql, $fname = '', $tempIgnore = false ) {
14 $this->lastQuery = $sql;
15
16 return true;
17 }
18
22 public function replaceVars( $s ) {
23 return parent::replaceVars( $s );
24 }
25}
26
34 protected $db;
35
36 protected function setUp() {
37 parent::setUp();
38
39 if ( !Sqlite::isPresent() ) {
40 $this->markTestSkipped( 'No SQLite support detected' );
41 }
43 if ( version_compare( $this->db->getServerVersion(), '3.6.0', '<' ) ) {
44 $this->markTestSkipped( "SQLite at least 3.6 required, {$this->db->getServerVersion()} found" );
45 }
46 }
47
48 private function replaceVars( $sql ) {
49 // normalize spacing to hide implementation details
50 return preg_replace( '/\s+/', ' ', $this->db->replaceVars( $sql ) );
51 }
52
53 private function assertResultIs( $expected, $res ) {
54 $this->assertNotNull( $res );
55 $i = 0;
56 foreach ( $res as $row ) {
57 foreach ( $expected[$i] as $key => $value ) {
58 $this->assertTrue( isset( $row->$key ) );
59 $this->assertEquals( $value, $row->$key );
60 }
61 $i++;
62 }
63 $this->assertEquals( count( $expected ), $i, 'Unexpected number of rows' );
64 }
65
66 public static function provideAddQuotes() {
67 return [
68 [ // #0: empty
69 '', "''"
70 ],
71 [ // #1: simple
72 'foo bar', "'foo bar'"
73 ],
74 [ // #2: including quote
75 'foo\'bar', "'foo''bar'"
76 ],
77 // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
78 [
79 "x\0y",
80 "x'780079'",
81 ],
82 [ // #4: blob object (must be represented as hex)
83 new Blob( "hello" ),
84 "x'68656c6c6f'",
85 ],
86 ];
87 }
88
93 public function testAddQuotes( $value, $expected ) {
94 // check quoting
96 $this->assertEquals( $expected, $db->addQuotes( $value ), 'string not quoted as expected' );
97
98 // ok, quoting works as expected, now try a round trip.
99 $re = $db->query( 'select ' . $db->addQuotes( $value ) );
100
101 $this->assertTrue( $re !== false, 'query failed' );
102
103 $row = $re->fetchRow();
104 if ( $row ) {
105 if ( $value instanceof Blob ) {
106 $value = $value->fetch();
107 }
108
109 $this->assertEquals( $value, $row[0], 'string mangled by the database' );
110 } else {
111 $this->fail( 'query returned no result' );
112 }
113 }
114
118 public function testReplaceVars() {
119 $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
120
121 $this->assertEquals(
122 "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
123 . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
124 $this->replaceVars(
125 "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, "
126 . "foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', "
127 . "foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;"
128 )
129 );
130
131 $this->assertEquals(
132 "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
133 $this->replaceVars(
134 "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );"
135 )
136 );
137
138 $this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
139 $this->replaceVars( "CREATE TABLE foo ( foo_binary1 binary(16), foo_binary2 varbinary(32) );" )
140 );
141
142 $this->assertEquals( "CREATE TABLE text ( text_foo TEXT );",
143 $this->replaceVars( "CREATE TABLE text ( text_foo tinytext );" ),
144 'Table name changed'
145 );
146
147 $this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
148 $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY NOT NULL AUTO_INCREMENT );" )
149 );
150 $this->assertEquals( "CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
151 $this->replaceVars( "CREATE TABLE foo ( foobar INT PRIMARY KEY AUTO_INCREMENT NOT NULL );" )
152 );
153
154 $this->assertEquals( "CREATE TABLE enums( enum1 TEXT, myenum TEXT)",
155 $this->replaceVars( "CREATE TABLE enums( enum1 ENUM('A', 'B'), myenum ENUM ('X', 'Y'))" )
156 );
157
158 $this->assertEquals( "ALTER TABLE foo ADD COLUMN foo_bar INTEGER DEFAULT 42",
159 $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" )
160 );
161
162 $this->assertEquals( "DROP INDEX foo",
163 $this->replaceVars( "DROP INDEX /*i*/foo ON /*_*/bar" )
164 );
165
166 $this->assertEquals( "DROP INDEX foo -- dropping index",
167 $this->replaceVars( "DROP INDEX /*i*/foo ON /*_*/bar -- dropping index" )
168 );
169 $this->assertEquals( "INSERT OR IGNORE INTO foo VALUES ('bar')",
170 $this->replaceVars( "INSERT OR IGNORE INTO foo VALUES ('bar')" )
171 );
172 }
173
177 public function testTableName() {
178 // @todo Moar!
180 $this->assertEquals( 'foo', $db->tableName( 'foo' ) );
181 $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) );
182 $db->tablePrefix( 'foo' );
183 $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) );
184 $this->assertEquals( 'foobar', $db->tableName( 'bar' ) );
185 }
186
190 public function testDuplicateTableStructure() {
192 $db->query( 'CREATE TABLE foo(foo, barfoo)' );
193 $db->query( 'CREATE INDEX index1 ON foo(foo)' );
194 $db->query( 'CREATE UNIQUE INDEX index2 ON foo(barfoo)' );
195
196 $db->duplicateTableStructure( 'foo', 'bar' );
197 $this->assertEquals( 'CREATE TABLE "bar"(foo, barfoo)',
198 $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'bar' ] ),
199 'Normal table duplication'
200 );
201 $indexList = $db->query( 'PRAGMA INDEX_LIST("bar")' );
202 $index = $indexList->next();
203 $this->assertEquals( 'bar_index1', $index->name );
204 $this->assertEquals( '0', $index->unique );
205 $index = $indexList->next();
206 $this->assertEquals( 'bar_index2', $index->name );
207 $this->assertEquals( '1', $index->unique );
208
209 $db->duplicateTableStructure( 'foo', 'baz', true );
210 $this->assertEquals( 'CREATE TABLE "baz"(foo, barfoo)',
211 $db->selectField( 'sqlite_temp_master', 'sql', [ 'name' => 'baz' ] ),
212 'Creation of temporary duplicate'
213 );
214 $indexList = $db->query( 'PRAGMA INDEX_LIST("baz")' );
215 $index = $indexList->next();
216 $this->assertEquals( 'baz_index1', $index->name );
217 $this->assertEquals( '0', $index->unique );
218 $index = $indexList->next();
219 $this->assertEquals( 'baz_index2', $index->name );
220 $this->assertEquals( '1', $index->unique );
221 $this->assertEquals( 0,
222 $db->selectField( 'sqlite_master', 'COUNT(*)', [ 'name' => 'baz' ] ),
223 'Create a temporary duplicate only'
224 );
225 }
226
232 if ( $db->getFulltextSearchModule() != 'FTS3' ) {
233 $this->markTestSkipped( 'FTS3 not supported, cannot create virtual tables' );
234 }
235 $db->query( 'CREATE VIRTUAL TABLE "foo" USING FTS3(foobar)' );
236
237 $db->duplicateTableStructure( 'foo', 'bar' );
238 $this->assertEquals( 'CREATE VIRTUAL TABLE "bar" USING FTS3(foobar)',
239 $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'bar' ] ),
240 'Duplication of virtual tables'
241 );
242
243 $db->duplicateTableStructure( 'foo', 'baz', true );
244 $this->assertEquals( 'CREATE VIRTUAL TABLE "baz" USING FTS3(foobar)',
245 $db->selectField( 'sqlite_master', 'sql', [ 'name' => 'baz' ] ),
246 "Can't create temporary virtual tables, should fall back to non-temporary duplication"
247 );
248 }
249
253 public function testDeleteJoin() {
255 $db->query( 'CREATE TABLE a (a_1)', __METHOD__ );
256 $db->query( 'CREATE TABLE b (b_1, b_2)', __METHOD__ );
257 $db->insert( 'a', [
258 [ 'a_1' => 1 ],
259 [ 'a_1' => 2 ],
260 [ 'a_1' => 3 ],
261 ],
262 __METHOD__
263 );
264 $db->insert( 'b', [
265 [ 'b_1' => 2, 'b_2' => 'a' ],
266 [ 'b_1' => 3, 'b_2' => 'b' ],
267 ],
268 __METHOD__
269 );
270 $db->deleteJoin( 'a', 'b', 'a_1', 'b_1', [ 'b_2' => 'a' ], __METHOD__ );
271 $res = $db->query( "SELECT * FROM a", __METHOD__ );
272 $this->assertResultIs( [
273 [ 'a_1' => 1 ],
274 [ 'a_1' => 3 ],
275 ],
276 $res
277 );
278 }
279
280 public function testEntireSchema() {
281 global $IP;
282
283 $result = Sqlite::checkSqlSyntax( "$IP/maintenance/tables.sql" );
284 if ( $result !== true ) {
285 $this->fail( $result );
286 }
287 $this->assertTrue( true ); // avoid test being marked as incomplete due to lack of assertions
288 }
289
294 public function testUpgrades() {
296
297 // Versions tested
298 $versions = [
299 // '1.13', disabled for now, was totally screwed up
300 // SQLite wasn't included in 1.14
301 '1.15',
302 '1.16',
303 '1.17',
304 '1.18',
305 ];
306
307 // Mismatches for these columns we can safely ignore
308 $ignoredColumns = [
309 'user_newtalk.user_last_timestamp', // r84185
310 ];
311
312 $currentDB = DatabaseSqlite::newStandaloneInstance( ':memory:' );
313 $currentDB->sourceFile( "$IP/maintenance/tables.sql" );
314
315 $profileToDb = false;
316 if ( isset( $wgProfiler['output'] ) ) {
317 $out = $wgProfiler['output'];
318 if ( $out === 'db' ) {
319 $profileToDb = true;
320 } elseif ( is_array( $out ) && in_array( 'db', $out ) ) {
321 $profileToDb = true;
322 }
323 }
324
325 if ( $profileToDb ) {
326 $currentDB->sourceFile( "$IP/maintenance/sqlite/archives/patch-profiling.sql" );
327 }
328 $currentTables = $this->getTables( $currentDB );
329 sort( $currentTables );
330
331 foreach ( $versions as $version ) {
332 $versions = "upgrading from $version to $wgVersion";
333 $db = $this->prepareTestDB( $version );
334 $tables = $this->getTables( $db );
335 $this->assertEquals( $currentTables, $tables, "Different tables $versions" );
336 foreach ( $tables as $table ) {
337 $currentCols = $this->getColumns( $currentDB, $table );
338 $cols = $this->getColumns( $db, $table );
339 $this->assertEquals(
340 array_keys( $currentCols ),
341 array_keys( $cols ),
342 "Mismatching columns for table \"$table\" $versions"
343 );
344 foreach ( $currentCols as $name => $column ) {
345 $fullName = "$table.$name";
346 $this->assertEquals(
347 (bool)$column->pk,
348 (bool)$cols[$name]->pk,
349 "PRIMARY KEY status does not match for column $fullName $versions"
350 );
351 if ( !in_array( $fullName, $ignoredColumns ) ) {
352 $this->assertEquals(
353 (bool)$column->notnull,
354 (bool)$cols[$name]->notnull,
355 "NOT NULL status does not match for column $fullName $versions"
356 );
357 $this->assertEquals(
358 $column->dflt_value,
359 $cols[$name]->dflt_value,
360 "Default values does not match for column $fullName $versions"
361 );
362 }
363 }
364 $currentIndexes = $this->getIndexes( $currentDB, $table );
365 $indexes = $this->getIndexes( $db, $table );
366 $this->assertEquals(
367 array_keys( $currentIndexes ),
368 array_keys( $indexes ),
369 "mismatching indexes for table \"$table\" $versions"
370 );
371 }
372 $db->close();
373 }
374 }
375
379 public function testInsertIdType() {
381
382 $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ );
383 $this->assertInstanceOf( 'ResultWrapper', $databaseCreation, "Database creation" );
384
385 $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ );
386 $this->assertTrue( $insertion, "Insertion worked" );
387
388 $this->assertInternalType( 'integer', $db->insertId(), "Actual typecheck" );
389 $this->assertTrue( $db->close(), "closing database" );
390 }
391
392 private function prepareTestDB( $version ) {
393 static $maint = null;
394 if ( $maint === null ) {
395 $maint = new FakeMaintenance();
396 $maint->loadParamsAndArgs( null, [ 'quiet' => 1 ] );
397 }
398
399 global $IP;
401 $db->sourceFile( "$IP/tests/phpunit/data/db/sqlite/tables-$version.sql" );
402 $updater = DatabaseUpdater::newForDB( $db, false, $maint );
403 $updater->doUpdates( [ 'core' ] );
404
405 return $db;
406 }
407
408 private function getTables( $db ) {
409 $list = array_flip( $db->listTables() );
410 $excluded = [
411 'external_user', // removed from core in 1.22
412 'math', // moved out of core in 1.18
413 'trackbacks', // removed from core in 1.19
414 'searchindex',
415 'searchindex_content',
416 'searchindex_segments',
417 'searchindex_segdir',
418 // FTS4 ready!!1
419 'searchindex_docsize',
420 'searchindex_stat',
421 ];
422 foreach ( $excluded as $t ) {
423 unset( $list[$t] );
424 }
425 $list = array_flip( $list );
426 sort( $list );
427
428 return $list;
429 }
430
431 private function getColumns( $db, $table ) {
432 $cols = [];
433 $res = $db->query( "PRAGMA table_info($table)" );
434 $this->assertNotNull( $res );
435 foreach ( $res as $col ) {
436 $cols[$col->name] = $col;
437 }
438 ksort( $cols );
439
440 return $cols;
441 }
442
443 private function getIndexes( $db, $table ) {
444 $indexes = [];
445 $res = $db->query( "PRAGMA index_list($table)" );
446 $this->assertNotNull( $res );
447 foreach ( $res as $index ) {
448 $res2 = $db->query( "PRAGMA index_info({$index->name})" );
449 $this->assertNotNull( $res2 );
450 $index->columns = [];
451 foreach ( $res2 as $col ) {
452 $index->columns[] = $col;
453 }
454 $indexes[$index->name] = $index;
455 }
456 ksort( $indexes );
457
458 return $indexes;
459 }
460
461 public function testCaseInsensitiveLike() {
462 // TODO: Test this for all databases
464 $res = $db->query( 'SELECT "a" LIKE "A" AS a' );
465 $row = $res->fetchRow();
466 $this->assertFalse( (bool)$row['a'] );
467 }
468
472 public function testNumFields() {
474
475 $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ );
476 $this->assertInstanceOf( 'ResultWrapper', $databaseCreation, "Failed to create table a" );
477 $res = $db->select( 'a', '*' );
478 $this->assertEquals( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" );
479 $insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ );
480 $this->assertTrue( $insertion, "Insertion failed" );
481 $res = $db->select( 'a', '*' );
482 $this->assertEquals( 1, $db->numFields( $res ), "wrong number of fields" );
483
484 $this->assertTrue( $db->close(), "closing database" );
485 }
486
487 public function testToString() {
489
490 $toString = (string)$db;
491
492 $this->assertContains( 'SQLite ', $toString );
493 }
494}
$wgVersion
MediaWiki version number.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
$IP
Definition WebStart.php:58
$wgProfiler
Definition WebStart.php:73
Utility class.
Definition Blob.php:8
replaceVars( $s)
Override parent visibility to public.
query( $sql, $fname='', $tempIgnore=false)
Run an SQL query and return the result.
static newInstance(array $p=[])
sqlite Database medium
testDuplicateTableStructureVirtual()
DatabaseSqlite::duplicateTableStructure.
testInsertIdType()
DatabaseSqlite::insertId.
assertResultIs( $expected, $res)
testAddQuotes( $value, $expected)
provideAddQuotes() DatabaseSqlite::addQuotes
testUpgrades()
Runs upgrades of older databases and compares results with current schema.
testReplaceVars()
DatabaseSqlite::replaceVars.
DatabaseSqliteMock $db
testTableName()
DatabaseSqlite::tableName.
testNumFields()
DatabaseSqlite::numFields.
testDuplicateTableStructure()
DatabaseSqlite::duplicateTableStructure.
testDeleteJoin()
DatabaseSqlite::deleteJoin.
tableName( $name, $format='quoted')
Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks.
static getFulltextSearchModule()
Returns version of currently supported SQLite fulltext search module or false if none present.
listTables( $prefix=null, $fname=__METHOD__)
List all tables on the database.
static newStandaloneInstance( $filename, array $p=[])
insertId()
This must be called after nextSequenceVal.
duplicateTableStructure( $oldName, $newName, $temporary=false, $fname=__METHOD__)
insert( $table, $a, $fname=__METHOD__, $options=[])
Based on generic method (parent) with some prior SQLite-sepcific adjustments.
static newForDB(Database $db, $shared=false, $maintenance=null)
close()
Closes a database connection.
Definition Database.php:705
tablePrefix( $prefix=null)
Get/set the table prefix.
Definition Database.php:448
static factory( $dbType, $p=[])
Construct a Database subclass instance given a database type and parameters.
Definition Database.php:325
lastQuery()
Return the last query that went through IDatabase::query()
Definition Database.php:510
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[])
A SELECT wrapper which returns a single field from a single result row.
sourceFile( $filename, callable $lineCallback=null, callable $resultCallback=null, $fname=false, callable $inputCallback=null)
Read and execute SQL commands from a file.
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
Fake maintenance wrapper, mostly used for the web installer/updater.
static isPresent()
Checks whether PHP has SQLite support.
Definition sqlite.inc:35
static checkSqlSyntax( $files)
Checks given files for correctness of SQL syntax.
Definition sqlite.inc:47
$res
Definition database.txt:21
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition hooks.txt:1028
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 '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! 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:Associative array mapping language codes to prefixed links of the form "language:title". & $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! 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:1937
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:183
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:886
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
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:37