29 use Wikimedia\AtEase\AtEase;
43 $this->mHandle = $handle;
50 return feof( $this->mHandle );
57 return fread( $this->mHandle, 32768 );
64 return stream_get_meta_data( $this->mHandle )[
'seekable'] ??
false;
71 public function seek(
int $offset ) {
72 return fseek( $this->mHandle, $offset );
80 AtEase::suppressWarnings();
81 $file = fopen( $filename,
'rt' );
82 AtEase::restoreWarnings();
95 $upload =& $_FILES[$fieldname];
97 if ( $upload ===
null || !$upload[
'name'] ) {
100 if ( !empty( $upload[
'error'] ) ) {
101 switch ( $upload[
'error'] ) {
102 case UPLOAD_ERR_INI_SIZE:
105 case UPLOAD_ERR_FORM_SIZE:
110 case UPLOAD_ERR_PARTIAL:
113 case UPLOAD_ERR_NO_TMP_DIR:
120 $fname = $upload[
'tmp_name'];
121 if ( is_uploaded_file( $fname ) ) {
134 $httpImportTimeout = MediaWikiServices::getInstance()->getMainConfig()->get(
135 MainConfigNames::HTTPImportTimeout );
136 wfDebug( __METHOD__ .
": opening $url" );
137 # Use the standard HTTP fetch function; it times out
138 # quicker and sorts out user-agent problems which might
139 # otherwise prevent importing from large sites, such
140 # as the Wikimedia cluster, etc.
141 $data = MediaWikiServices::getInstance()->getHttpRequestFactory()->request(
145 'followRedirects' =>
true,
146 'timeout' => $httpImportTimeout
150 if ( $data !==
null ) {
152 fwrite(
$file, $data );
170 $templates =
false, $pageLinkDepth = 0
176 # Look up the first interwiki prefix, and let the foreign site handle
177 # subsequent interwiki prefixes
178 $firstIwPrefix = strtok( $interwiki,
':' );
179 $interwikiLookup = MediaWikiServices::getInstance()->getInterwikiLookup();
180 $firstIw = $interwikiLookup->fetch( $firstIwPrefix );
185 $additionalIwPrefixes = strtok(
'' );
186 if ( $additionalIwPrefixes ) {
187 $additionalIwPrefixes .=
':';
189 # Have to do a DB-key replacement ourselves; otherwise spaces get
190 # URL-encoded to +, which is wrong in this case. Similar to logic in
192 $link = $firstIw->getURL( strtr(
"{$additionalIwPrefixes}Special:Export/$page",
197 $params[
'history'] = 1;
200 $params[
'templates'] = 1;
202 if ( $pageLinkDepth ) {
203 $params[
'pagelink-depth'] = $pageLinkDepth;
207 # For interwikis, use POST to avoid redirects.
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...
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')
A class containing constants representing the names of configuration variables.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
Source interface for XML import.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.