* @ingroup Dump
*/
class XmlDumpWriter {
- protected $firstPageWritten = 0, $lastPageWritten = 0, $pageInProgress = 0;
-
/**
* Returns the export schema version.
* @return string
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
$out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
- $this->pageInProgress = $row->page_id;
if ( $row->page_is_redirect ) {
$out .= ' ' . Xml::element( 'redirect', array() ) . "\n";
}
*/
function closePage() {
return " </page>\n";
- if ( !$this->firstPageWritten ) {
- $this->firstPageWritten = $this->pageInProgress;
- }
- $this->lastPageWritten = $this->pageInProgress;
}
/**
/**
* Close the old file, and move it to a specified name.
- * Use this for the last piece of a file written out
+ * Use this for the last piece of a file written out
* at specified checkpoints (e.g. every n hours).
* @param $newname mixed File name. May be a string or an array with one element
* @param $open bool If true, a new file with the old filename will be opened again for writing (default: false)
}
if ( $newname ) {
fclose( $this->handle );
- rename( $this->filename, $newname );
- if ( $open ) {
+ if (! rename( $this->filename, $newname ) ) {
+ throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" );
+ }
+ elseif ( $open ) {
$this->handle = fopen( $this->filename, "wt" );
}
}
if ( $newname ) {
fclose( $this->handle );
proc_close( $this->procOpenResource );
- rename( $this->filename, $newname );
- if ( $open ) {
+ if (! rename( $this->filename, $newname ) ) {
+ throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" );
+ }
+ elseif ( $open ) {
$command = $this->command;
$command .= " > " . wfEscapeShellArg( $this->filename );
$this->startCommand( $command );
if ( $newname ) {
fclose( $this->handle );
proc_close( $this->procOpenResource );
- rename( $this->filename, $newname );
- if ( $open ) {
+ if (! rename( $this->filename, $newname ) ) {
+ throw new MWException( __METHOD__ . ": rename of file {$this->filename} to $newname failed\n" );
+ }
+ elseif ( $open ) {
$command = "7za a -bd -si " . wfEscapeShellArg( $file );
// Suppress annoying useless crap from p7zip
// Unfortunately this could suppress real error messages too