34 $this->mHandle = $handle;
41 return feof( $this->mHandle );
48 return fread( $this->mHandle, 32768 );
56 Wikimedia\suppressWarnings();
57 $file = fopen( $filename,
'rt' );
58 Wikimedia\restoreWarnings();
60 return Status::newFatal(
"importcantopen" );
70 $upload =& $_FILES[$fieldname];
72 if ( $upload ===
null || !$upload[
'name'] ) {
73 return Status::newFatal(
'importnofile' );
75 if ( !empty( $upload[
'error'] ) ) {
76 switch ( $upload[
'error'] ) {
77 case UPLOAD_ERR_INI_SIZE:
79 return Status::newFatal(
'importuploaderrorsize' );
80 case UPLOAD_ERR_FORM_SIZE:
84 return Status::newFatal(
'importuploaderrorsize' );
85 case UPLOAD_ERR_PARTIAL:
87 return Status::newFatal(
'importuploaderrorpartial' );
88 case UPLOAD_ERR_NO_TMP_DIR:
90 return Status::newFatal(
'importuploaderrortemp' );
95 $fname = $upload[
'tmp_name'];
96 if ( is_uploaded_file(
$fname ) ) {
99 return Status::newFatal(
'importnofile' );
110 wfDebug( __METHOD__ .
": opening $url\n" );
111 # Use the standard HTTP fetch function; it times out
112 # quicker and sorts out user-agent problems which might
113 # otherwise prevent importing from large sites, such
114 # as the Wikimedia cluster, etc.
119 'followRedirects' =>
true,
124 if (
$data !==
false ) {
131 return Status::newFatal(
'importcantopen' );
144 $templates =
false, $pageLinkDepth = 0
147 return Status::newFatal(
'import-noarticle' );
150 # Look up the first interwiki prefix, and let the foreign site handle
151 # subsequent interwiki prefixes
152 $firstIwPrefix = strtok( $interwiki,
':' );
153 $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
154 $firstIw = $interwikiLookup->fetch( $firstIwPrefix );
156 return Status::newFatal(
'importbadinterwiki' );
159 $additionalIwPrefixes = strtok(
'' );
160 if ( $additionalIwPrefixes ) {
161 $additionalIwPrefixes .=
':';
163 # Have to do a DB-key replacement ourselves; otherwise spaces get
164 # URL-encoded to +, which is wrong in this case. Similar to logic in
166 $link = $firstIw->getURL( strtr(
"${additionalIwPrefixes}Special:Export/$page",
176 if ( $pageLinkDepth ) {
177 $params[
'pagelink-depth'] = $pageLinkDepth;
181 # For interwikis, use POST to avoid redirects.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgHTTPImportTimeout
Timeout for HTTP requests done internally for transwiki imports, in seconds.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
static request( $method, $url, array $options=[], $caller=__METHOD__)
Perform an HTTP request.
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 newFromFile( $filename)
static newFromUpload( $fieldname="xmlimport")
static newFromURL( $url, $method='GET')
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file