/**
* Creates an ImportXMLReader drawing from the source provided
- */
+ */
function __construct( $source ) {
$this->reader = new XMLReader();
stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' );
$id = UploadSourceAdapter::registerSource( $source );
- $this->reader->open( "uploadsource://$id" );
+ if (defined( 'LIBXML_PARSEHUGE' ) ) {
+ $this->reader->open( "uploadsource://$id", null, LIBXML_PARSEHUGE );
+ }
+ else {
+ $this->reader->open( "uploadsource://$id" );
+ }
// Default callbacks
$this->setRevisionCallback( array( $this, "importRevision" ) );
// Don't override namespaces
$this->mTargetNamespace = null;
} elseif( $namespace >= 0 ) {
- // FIXME: Check for validity
+ // @todo FIXME: Check for validity
$this->mTargetNamespace = intval( $namespace );
} else {
return false;
if( $user ) {
$userId = intval( $user->getId() );
$userText = $user->getName();
+ $userObj = $user;
} else {
$userId = 0;
$userText = $this->getUser();
+ $userObj = new User;
}
// avoid memory leak...?
# must create the page...
$pageId = $article->insertOn( $dbw );
$created = true;
+ $oldcountable = null;
} else {
$created = false;
__METHOD__
);
if( $prior ) {
- // FIXME: this could fail slightly for multiple matches :P
+ // @todo FIXME: This could fail slightly for multiple matches :P
wfDebug( __METHOD__ . ": skipping existing revision for [[" .
$this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n" );
return false;
}
+ $oldcountable = $article->isCountable();
}
- # FIXME: Use original rev_id optionally (better for backups)
+ # @todo FIXME: Use original rev_id optionally (better for backups)
# Insert the row
$revision = new Revision( array(
'page' => $pageId,
'timestamp' => $this->timestamp,
'minor_edit' => $this->minor,
) );
- $revId = $revision->insertOn( $dbw );
+ $revision->insertOn( $dbw );
$changed = $article->updateIfNewerOn( $dbw, $revision );
- # To be on the safe side...
- $tempTitle = $GLOBALS['wgTitle'];
- $GLOBALS['wgTitle'] = $this->title;
-
- if ( $created ) {
- wfDebug( __METHOD__ . ": running onArticleCreate\n" );
- Article::onArticleCreate( $this->title );
- } elseif( $changed ) {
- wfDebug( __METHOD__ . ": running onArticleEdit\n" );
- Article::onArticleEdit( $this->title );
+ if ( $changed !== false ) {
+ wfDebug( __METHOD__ . ": running updates\n" );
+ $article->doEditUpdates( $revision, $userObj, array( 'created' => $created, 'oldcountable' => $oldcountable ) );
}
- wfDebug( __METHOD__ . ": running updates\n" );
- $article->editUpdates(
- $this->getText(),
- $this->getComment(),
- $this->minor,
- $this->timestamp,
- $revId,
- true,
- null,
- $created );
-
- $GLOBALS['wgTitle'] = $tempTitle;
-
return true;
}
function importLogItem() {
$dbw = wfGetDB( DB_MASTER );
- # FIXME: this will not record autoblocks
+ # @todo FIXME: This will not record autoblocks
if( !$this->getTitle() ) {
wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
$this->timestamp . "\n" );
return;
}
# Check if it exists already
- // FIXME: use original log ID (better for backups)
+ // @todo FIXME: Use original log ID (better for backups)
$prior = $dbw->selectField( 'logging', '1',
array( 'log_type' => $this->getType(),
'log_action' => $this->getAction(),
'log_params' => $this->params ),
__METHOD__
);
- // FIXME: this could fail slightly for multiple matches :P
+ // @todo FIXME: This could fail slightly for multiple matches :P
if( $prior ) {
wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
$this->timestamp . "\n" );
}
$sha1 = $this->getSha1();
if ( $sha1 && ( $sha1 !== sha1_file( $source ) ) ) {
+ if ( $flags & File::DELETE_SOURCE ) {
+ # Broken file; delete it if it is a temporary file
+ unlink( $source );
+ }
wfDebug( __METHOD__ . ": Corrupt file $source.\n" );
return false;
}
return false;
}
- // @todo Fixme!
+ // @todo FIXME!
$src = $this->getSrc();
$data = Http::get( $src );
if( !$data ) {
}
static function newFromFile( $filename ) {
- $file = @fopen( $filename, 'rt' );
+ wfSuppressWarnings();
+ $file = fopen( $filename, 'rt' );
+ wfRestoreWarnings();
if( !$file ) {
return Status::newFatal( "importcantopen" );
}