29 MediaWikiServices::getInstance()->getMainConfig()
32 $importer->doImport();
34 $this->assertTrue(
$title->exists() );
36 $this->assertEquals( WikiPage::factory(
$title )->getContent()->getNativeData(), $text );
44<mediawiki xmlns=
"http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version=
"0.10" xml:lang=
"en">
45 <
page unknown=
"123" dontknow=
"533">
47 <unknowntag>Should be ignored</unknowntag>
49 <
id unknown=
"123" dontknow=
"533">14</
id>
51 <
id unknown=
"123" dontknow=
"533">15</
id>
52 <unknowntag>Should be ignored</unknowntag>
53 <timestamp>2016-01-03T11:18:43Z</timestamp>
55 <unknowntag>Should be ignored</unknowntag>
56 <username unknown=
"123" dontknow=
"533">Admin</username>
59 <model>wikitext</model>
61 <
text xml:space=
"preserve" bytes=
"0">noitazinagro tseb eht si ikiWaideM</
text>
62 <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
63 <unknowntag>Should be ignored</unknowntag>
66 <unknowntag>Should be ignored</unknowntag>
70 'noitazinagro tseb eht si ikiWaideM',
88 $sRevCount, $pageInfo )
use ( &$redirect ) {
89 if ( array_key_exists(
'redirect', $pageInfo ) ) {
90 $redirect = $pageInfo[
'redirect'];
96 MediaWikiServices::getInstance()->getMainConfig()
98 $importer->setPageOutCallback( $callback );
99 $importer->doImport();
101 $this->assertEquals( $redirectTitle, $redirect );
109<mediawiki xmlns=
"http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version=
"0.10" xml:lang=
"en">
117 <timestamp>2014-05-27T10:00:00Z</timestamp>
119 <username>Admin</username>
122 <comment>Admin moved
page [[Test]] to [[Test22]]</comment>
123 <model>wikitext</model>
125 <
text xml:space=
"preserve" bytes=
"20">#REDIRECT [[Test22]]</
text>
126 <sha1>tq456o9x3abm7r9ozi6km8yrbbc56o6</sha1>
136<mediawiki xmlns=
"http://www.mediawiki.org/xml/export-0.9/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://www.mediawiki.org/xml/export-0.9/ http://www.mediawiki.org/xml/export-0.9.xsd" version=
"0.9" xml:lang=
"en">
143 <timestamp>2014-05-27T11:00:00Z</timestamp>
145 <username>Admin</username>
148 <
text xml:space=
"preserve" bytes=
"4">Abcd</
text>
149 <sha1>n7uomjq96szt60fy5w3x7ahf7q8m8rh</sha1>
150 <model>wikitext</model>
172 $importNamespaces =
null;
173 $callback =
function (
array $siteinfo, $innerImporter )
use ( &$importNamespaces ) {
174 $importNamespaces = $siteinfo[
'_namespaces'];
179 MediaWikiServices::getInstance()->getMainConfig()
181 $importer->setSiteInfoCallback( $callback );
182 $importer->doImport();
184 $this->assertEquals( $importNamespaces,
$namespaces );
192<mediawiki xmlns=
"http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version=
"0.10" xml:lang=
"en">
195 <
namespace key=
"-2" case=
"first-letter">Media</
namespace>
196 <
namespace key=
"-1" case=
"first-letter">
Special</
namespace>
197 <
namespace key=
"0" case=
"first-letter" />
198 <
namespace key=
"1" case=
"first-letter">Talk</
namespace>
199 <
namespace key=
"2" case=
"first-letter">
User</
namespace>
200 <
namespace key=
"3" case=
"first-letter">
User talk</
namespace>
201 <
namespace key=
"100" case=
"first-letter">Portal</
namespace>
202 <
namespace key=
"101" case=
"first-letter">Portal talk</
namespace>
216 '101' =>
'Portal talk',
231 'ImportHandleUnknownUser' => [
function (
$name )
use ( $assign, $create, &$hookId ) {
233 $this->fail(
'ImportHandleUnknownUser was called unexpectedly' );
236 $this->assertEquals(
'UserDoesNotExist',
$name );
239 $this->assertNotNull(
$user );
240 $hookId =
$user->getId();
249 $n = ( $assign ? 1 : 0 ) + ( $create ? 2 : 0 );
253<mediawiki xmlns=
"http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version=
"0.10" xml:lang=
"en">
260 <timestamp>2016-01-01T0$n:00:00Z</timestamp>
262 <username>UserDoesNotExist</username>
265 <model>wikitext</model>
267 <
text xml:space=
"preserve" bytes=
"3">foo</
text>
268 <sha1>1e6gpc3ehk0mu2jqu8cg42g009s796b</sha1>
272 <timestamp>2016-01-01T0$n:00:01Z</timestamp>
274 <username>{
$user->getName()}</username>
275 <
id>{
$user->getId()}</
id>
277 <model>wikitext</model>
279 <
text xml:space=
"preserve" bytes=
"3">bar</
text>
280 <sha1>bjhlo6dxh5wivnszm93u4b78fheiy4t</sha1>
288 $importer =
new WikiImporter(
$source, MediaWikiServices::getInstance()->getMainConfig() );
289 $importer->setUsernamePrefix(
'Xxx', $assign );
290 $importer->doImport();
298 [
'rev_timestamp' =>
$db->
timestamp(
"201601010{$n}0000" ) ],
304 $assign && $create ?
'UserDoesNotExist' :
'Xxx>UserDoesNotExist',
307 $this->assertSame( $assign && $create ? $hookId : 0, (int)$row->rev_user );
312 [
'rev_timestamp' =>
$db->
timestamp(
"201601010{$n}0001" ) ],
317 $this->assertSame( ( $assign ?
'' :
'Xxx>' ) .
$user->getName(), $row->rev_user_text );
318 $this->assertSame( $assign ?
$user->getId() : 0, (int)$row->rev_user );
323 'no assign' => [
false,
false ],
324 'assign, no create' => [
true,
false ],
325 'assign, create' => [
true,
true ],
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second redirect
to move a page</td >< td > &*You are moving the page across namespaces
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
A simple, immutable structure to hold the title of a page on a foreign MediaWiki installation.
Used for importing XML dumps where the content of the dump is in a string.
Test class for Import methods.
testSiteInfoContainsNamespaces( $xml, $namespaces)
WikiImporter::handleSiteInfo getSiteInfoXML.
testUnknownXMLTags( $xml, $text, $title)
WikiImporter getUnknownTagsXML.
static provideUnknownUserHandling()
testHandlePageContainsRedirect( $xml, $redirectTitle)
WikiImporter::handlePage getRedirectXML.
testUnknownUserHandling( $assign, $create)
provideUnknownUserHandling
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static createNew( $name, $params=[])
Add a user to the database, return the user object.
XML file reader for the page data importer.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace and then decline to actually register it & $namespaces
namespace and then decline to actually register it file or subcat img or subcat $title
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
if the prop value should be in the metadata multi language array format
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
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
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
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki