* @ingroup Dump
*/
class DumpFileOutput extends DumpOutput {
- protected $handle, $filename;
+ protected $handle = false, $filename;
function __construct( $file ) {
$this->handle = fopen( $file, "wt" );
function writeCloseStream( $string ) {
parent::writeCloseStream( $string );
- fclose( $this->handle );
+ if ( $this->handle ) {
+ fclose( $this->handle );
+ $this->handle = false;
+ }
}
function write( $string ) {
function closeAndRename( $newname, $open = false ) {
$newname = $this->checkRenameArgCount( $newname );
if ( $newname ) {
- fclose( $this->handle );
+ if ( $this->handle ) {
+ fclose( $this->handle );
+ $this->handle = false;
+ }
$this->renameOrException( $newname );
if ( $open ) {
$this->handle = fopen( $this->filename, "wt" );
*/
class DumpPipeOutput extends DumpFileOutput {
protected $command, $filename;
+ private $procOpenResource = false;
function __construct( $command, $file = null ) {
if ( !is_null( $file ) ) {
function writeCloseStream( $string ) {
parent::writeCloseStream( $string );
- proc_close( $this->procOpenResource );
+ if ( $this->procOpenResource ) {
+ proc_close( $this->procOpenResource );
+ $this->procOpenResource = false;
+ }
}
function startCommand( $command ) {
function closeAndRename( $newname, $open = false ) {
$newname = $this->checkRenameArgCount( $newname );
if ( $newname ) {
- fclose( $this->handle );
- proc_close( $this->procOpenResource );
+ if ( $this->handle ) {
+ fclose( $this->handle );
+ $this->handle = false;
+ }
+ if ( $this->procOpenResource ) {
+ proc_close( $this->procOpenResource );
+ $this->procOpenResource = false;
+ }
$this->renameOrException( $newname );
if ( $open ) {
$command = $this->command;