https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114982

Revision: 114982
Author:   catrope
Date:     2012-04-19 22:17:01 +0000 (Thu, 19 Apr 2012)
Log Message:
-----------
Followup to r114955: remove symlinks first, then the directories. Also complain 
when removing failed.

Modified Paths:
--------------
    trunk/tools/mwmultiversion/multiversion/deleteMediaWiki

Modified: trunk/tools/mwmultiversion/multiversion/deleteMediaWiki
===================================================================
--- trunk/tools/mwmultiversion/multiversion/deleteMediaWiki     2012-04-19 
21:47:02 UTC (rev 114981)
+++ trunk/tools/mwmultiversion/multiversion/deleteMediaWiki     2012-04-19 
22:17:01 UTC (rev 114982)
@@ -38,13 +38,24 @@
 
        # Destroy symlinks created by checkoutMediaWiki outside of $destIP
        $symlinks = array(
+               "$commonHomeDir/docroot/bits/static-$dstVersionNum/skins",
+               "$commonHomeDir/docroot/bits/static-$dstVersionNum/extensions",
+               "$commonHomeDir/docroot/bits/static-$dstVersionNum/resources",
+               "$commonHomeDir/docroot/secure/skins-$dstVersionNum",
+               "$commonHomeDir/live-1.5/static-$dstVersionNum/skins",
+               "$commonHomeDir/live-1.5/static-$dstVersionNum/extensions",
+               "$commonHomeDir/live-1.5/static-$dstVersionNum/resources",
+       );
+       $directories = array(
                "$commonHomeDir/docroot/bits/static-$dstVersionNum",
-               "$commonHomeDir/docroot/secure/skins-$dstVersionNum",
                "$commonHomeDir/live-1.5/static-$dstVersionNum",
        );
        foreach ( $symlinks as $path ) {
                deleteSymlink( $path );
        }
+       foreach ( $directories as $dir ) {
+               deleteDirectory( $dir );
+       }
 
        print "\nReferences to MediaWiki $dstVersionNum deleted.\n";
 }
@@ -57,8 +68,24 @@
        } else {
                if ( unlink( $path ) ) {
                        print "Symlink file removed: $path\n";
+               } else {
+                       print "COULD NOT REMOVE SYMLINK: $path\n";
                }
        }
 }
 
+function deleteDirectory( $path ) {
+       if ( !file_exists( $path ) ) {
+               print "Directory already removed: $path\n";
+       } elseif ( filetype( $path ) !== 'dir' ) { // sanity
+               print "Expected directory is not actually a directory: $path\n";
+       } else {
+               if ( rmdir( $path ) ) {
+                       print "Directory removed: $path\n";
+               } else {
+                       print "COULD NOT REMOVE DIRECTORY: $path\n";
+               }
+       }
+}
+
 deleteMediaWiki();


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

Reply via email to