Go to the documentation of this file.
40 $this->mHandle = $handle;
47 return feof( $this->mHandle );
54 return fread( $this->mHandle, 32768 );
62 Wikimedia\suppressWarnings();
63 $file = fopen( $filename,
'rt' );
64 Wikimedia\restoreWarnings();
76 $upload =& $_FILES[$fieldname];
78 if ( $upload ===
null || !$upload[
'name'] ) {
81 if ( !empty( $upload[
'error'] ) ) {
82 switch ( $upload[
'error'] ) {
83 case UPLOAD_ERR_INI_SIZE:
86 case UPLOAD_ERR_FORM_SIZE:
91 case UPLOAD_ERR_PARTIAL:
94 case UPLOAD_ERR_NO_TMP_DIR:
101 $fname = $upload[
'tmp_name'];
102 if ( is_uploaded_file( $fname ) ) {
116 wfDebug( __METHOD__ .
": opening $url\n" );
117 # Use the standard HTTP fetch function; it times out
118 # quicker and sorts out user-agent problems which might
119 # otherwise prevent importing from large sites, such
120 # as the Wikimedia cluster, etc.
121 $data = MediaWikiServices::getInstance()->getHttpRequestFactory()->request(
125 'followRedirects' =>
true,
130 if ( $data !==
false ) {
132 fwrite(
$file, $data );
150 $templates =
false, $pageLinkDepth = 0
156 # Look up the first interwiki prefix, and let the foreign site handle
157 # subsequent interwiki prefixes
158 $firstIwPrefix = strtok( $interwiki,
':' );
159 $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
160 $firstIw = $interwikiLookup->fetch( $firstIwPrefix );
165 $additionalIwPrefixes = strtok(
'' );
166 if ( $additionalIwPrefixes ) {
167 $additionalIwPrefixes .=
':';
169 # Have to do a DB-key replacement ourselves; otherwise spaces get
170 # URL-encoded to +, which is wrong in this case. Similar to logic in
172 $link = $firstIw->getURL( strtr(
"${additionalIwPrefixes}Special:Export/$page",
177 $params[
'history'] = 1;
180 $params[
'templates'] = 1;
182 if ( $pageLinkDepth ) {
183 $params[
'pagelink-depth'] = $pageLinkDepth;
187 # For interwikis, use POST to avoid redirects.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Imports a XML dump from a file (either from file upload, files on disk, or HTTP)
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
static newFromFile( $filename)
static newFromURL( $url, $method='GET')
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
static newGood( $value=null)
Factory function for good results.
Source interface for XML import.
$wgHTTPImportTimeout
Timeout for HTTP requests done internally for transwiki imports, in seconds.
static newFromUpload( $fieldname="xmlimport")