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'] ) {
78 # The uploaded file exceeds the upload_max_filesize directive in php.ini.
79 return Status::newFatal(
'importuploaderrorsize' );
81 # The uploaded file exceeds the MAX_FILE_SIZE directive that
82 # was specified in the HTML form.
83 return Status::newFatal(
'importuploaderrorsize' );
85 # The uploaded file was only partially uploaded
86 return Status::newFatal(
'importuploaderrorpartial' );
88 # Missing a temporary folder.
89 return Status::newFatal(
'importuploaderrortemp' );
90 # case else: # Currently impossible
94 $fname = $upload[
'tmp_name'];
95 if ( is_uploaded_file(
$fname ) ) {
98 return Status::newFatal(
'importnofile' );
109 wfDebug( __METHOD__ .
": opening $url\n" );
110 # Use the standard HTTP fetch function; it times out
111 # quicker and sorts out user-agent problems which might
112 # otherwise prevent importing from large sites, such
113 # as the Wikimedia cluster, etc.
118 'followRedirects' =>
true,
123 if ( $data !==
false ) {
125 fwrite( $file, $data );
130 return Status::newFatal(
'importcantopen' );
143 $templates =
false, $pageLinkDepth = 0
146 return Status::newFatal(
'import-noarticle' );
149 # Look up the first interwiki prefix, and let the foreign site handle
150 # subsequent interwiki prefixes
151 $firstIwPrefix = strtok( $interwiki,
':' );
152 $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
153 $firstIw = $interwikiLookup->fetch( $firstIwPrefix );
155 return Status::newFatal(
'importbadinterwiki' );
158 $additionalIwPrefixes = strtok(
'' );
159 if ( $additionalIwPrefixes ) {
160 $additionalIwPrefixes .=
':';
162 # Have to do a DB-key replacement ourselves; otherwise spaces get
163 # URL-encoded to +, which is wrong in this case. Similar to logic in
165 $link = $firstIw->getURL( strtr(
"${additionalIwPrefixes}Special:Export/$page",
175 if ( $pageLinkDepth ) {
176 $params[
'pagelink-depth'] = $pageLinkDepth;
180 # For interwikis, use POST to avoid redirects.
$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, $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')
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Source interface for XML import.