http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97178

Revision: 97178
Author:   ariel
Date:     2011-09-15 17:18:13 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
throw exception if rename of output file fails

Modified Paths:
--------------
    trunk/phase3/includes/Export.php

Modified: trunk/phase3/includes/Export.php
===================================================================
--- trunk/phase3/includes/Export.php    2011-09-15 16:42:22 UTC (rev 97177)
+++ trunk/phase3/includes/Export.php    2011-09-15 17:18:13 UTC (rev 97178)
@@ -759,8 +759,10 @@
                }
                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" );
                        }
                }
@@ -814,8 +816,10 @@
                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 );
@@ -873,8 +877,10 @@
                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


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to