34 $this->mHandle = $handle;
41 return feof( $this->mHandle );
48 return fread( $this->mHandle, 32768 );
57 $file =
fopen( $filename,
'rt' );
60 return Status::newFatal(
"importcantopen" );
72 if ( $upload ===
null || !$upload[
'name'] ) {
73 return Status::newFatal(
'importnofile' );
75 if ( !empty( $upload[
'error'] ) ) {
76 switch ( $upload[
'error'] ) {
79 return Status::newFatal(
'importuploaderrorsize' );
84 return Status::newFatal(
'importuploaderrorsize' );
87 return Status::newFatal(
'importuploaderrorpartial' );
90 return Status::newFatal(
'importuploaderrortemp' );
95 $fname = $upload[
'tmp_name'];
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.
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$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')
usually copyright or history_copyright This message must be in HTML not wikitext & $link
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Source interface for XML import.