33 $this->mHandle = $handle;
40 return feof( $this->mHandle );
47 return fread( $this->mHandle, 32768 );
55 MediaWiki\suppressWarnings();
56 $file = fopen( $filename,
'rt' );
57 MediaWiki\restoreWarnings();
69 $upload =& $_FILES[$fieldname];
71 if ( $upload === null || !$upload[
'name'] ) {
74 if ( !empty( $upload[
'error'] ) ) {
75 switch ( $upload[
'error'] ) {
77 # The uploaded file exceeds the upload_max_filesize directive in php.ini.
80 # The uploaded file exceeds the MAX_FILE_SIZE directive that
81 # was specified in the HTML form.
84 # The uploaded file was only partially uploaded
87 # Missing a temporary folder.
89 # case else: # Currently impossible
93 $fname = $upload[
'tmp_name'];
94 if ( is_uploaded_file(
$fname ) ) {
107 wfDebug( __METHOD__ .
": opening $url\n" );
108 # Use the standard HTTP fetch function; it times out
109 # quicker and sorts out user-agent problems which might
110 # otherwise prevent importing from large sites, such
111 # as the Wikimedia cluster, etc.
112 $data =
Http::request( $method, $url, [
'followRedirects' =>
true ], __METHOD__ );
113 if ( $data !==
false ) {
115 fwrite( $file, $data );
133 $templates =
false, $pageLinkDepth = 0
139 # Look up the first interwiki prefix, and let the foreign site handle
140 # subsequent interwiki prefixes
141 $firstIwPrefix = strtok( $interwiki,
':' );
147 $additionalIwPrefixes = strtok(
'' );
148 if ( $additionalIwPrefixes ) {
149 $additionalIwPrefixes .=
':';
151 # Have to do a DB-key replacement ourselves; otherwise spaces get
152 # URL-encoded to +, which is wrong in this case. Similar to logic in
154 $link = $firstIw->getURL( strtr(
"${additionalIwPrefixes}Special:Export/$page",
164 if ( $pageLinkDepth ) {
165 $params[
'pagelink-depth'] = $pageLinkDepth;
169 # For interwikis, use POST to avoid redirects.
static newFatal($message)
Factory function for fatal errors.
static newFromURL($url, $method= 'GET')
static request($method, $url, $options=[], $caller=__METHOD__)
Perform an HTTP request.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Imports a XML dump from a file (either from file upload, files on disk, or HTTP)
static newFromInterwiki($interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
static newGood($value=null)
Factory function for good results.
static fetch($prefix)
Fetch an Interwiki object.
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
Source interface for XML import.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
static newFromUpload($fieldname="xmlimport")
static newFromFile($filename)
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 $page