67 $xml = file_get_contents( $file );
69 if ( $xml ===
false ) {
82 $document =
new DOMDocument();
84 $oldLibXmlErrors = libxml_use_internal_errors(
true );
85 $ok = $document->loadXML( $xml, LIBXML_NONET );
88 $errors = libxml_get_errors();
89 libxml_use_internal_errors( $oldLibXmlErrors );
91 foreach ( $errors
as $error ) {
94 'Malformed XML: ' . $error->message .
' in line ' . $error->line
101 libxml_use_internal_errors( $oldLibXmlErrors );
110 $this->
store->saveSites( $sites );
123 $oldSites = $this->
store->getSites();
125 $current = $root->firstChild;
127 if ( $current instanceof DOMElement && $current->tagName ===
'site' ) {
129 $site = $this->
makeSite( $current );
130 $key = $site->getGlobalId();
132 if ( $oldSites->hasSite( $key ) ) {
133 $oldSite = $oldSites->getSite( $key );
134 $site->setInternalId( $oldSite->getInternalId() );
137 $sites[$key] = $site;
143 $current = $current->nextSibling;
155 public function makeSite( DOMElement $siteElement ) {
156 if ( $siteElement->tagName !==
'site' ) {
163 $site->setForward( $this->
hasChild( $siteElement,
'forward' ) );
164 $site->setGlobalId( $this->
getChildText( $siteElement,
'globalid' ) );
168 $pathTags = $siteElement->getElementsByTagName(
'path' );
169 for ( $i = 0; $i < $pathTags->length; $i++ ) {
170 $pathElement = $pathTags->item( $i );
172 $path = $pathElement->textContent;
174 $site->setPath( $pathType,
$path );
177 $idTags = $siteElement->getElementsByTagName(
'localid' );
178 for ( $i = 0; $i < $idTags->length; $i++ ) {
179 $idElement = $idTags->item( $i );
181 $id = $idElement->textContent;
183 $site->addLocalId( $idType, $id );
201 $node = $element->getAttributeNode(
$name );
204 if ( $default !==
false ) {
208 'Required ' .
$name .
' attribute not found in <' . $element->tagName .
'> tag'
213 return $node->textContent;
225 $elements = $element->getElementsByTagName(
$name );
227 if ( $elements->length < 1 ) {
228 if ( $default !==
false ) {
232 'Required <' .
$name .
'> tag not found inside <' . $element->tagName .
'> tag'
237 $node = $elements->item( 0 );
238 return $node->textContent;
256 if ( $this->exceptionCallback ) {
257 call_user_func( $this->exceptionCallback, $ex );
importFromDOM(DOMElement $root)
hasChild(DOMElement $element, $name)
getChildText(DOMElement $element, $name, $default=false)
MediaWiki s SiteStore can be cached and stored in a flat in a json format If the SiteStore is frequently the file cache may provide a performance benefit over a database store
setExceptionCallback($exceptionCallback)
getAttributeValue(DOMElement $element, $name, $default=false)
callable null $exceptionCallback
makeSiteList(DOMElement $root)
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
handleException(Exception $ex)
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
makeSite(DOMElement $siteElement)
wfLogWarning($msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
__construct(SiteStore $store)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
static newForType($siteType)
Allows to change the fields on the form that will be generated $name