move wfRecursiveRemoveDir to global functions
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 24 Feb 2012 15:41:06 +0000 (15:41 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 24 Feb 2012 15:41:06 +0000 (15:41 +0000)
That useful method was hidden in SeleniumWebSettings. I need it to clean
up test files leakages.

includes/GlobalFunctions.php
includes/SeleniumWebSettings.php

index 77820ea..3151755 100644 (file)
@@ -2615,6 +2615,29 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
        return $ok;
 }
 
+/**
+ * Remove a directory and all its content.
+ * Does not hide error.
+ */
+function wfRecursiveRemoveDir( $dir ) {
+       wfDebug( __FUNCTION__ . "( $dir )\n" );
+       // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
+       if ( is_dir( $dir ) ) {
+               $objects = scandir( $dir );
+               foreach ( $objects as $object ) {
+                       if ( $object != "." && $object != ".." ) {
+                               if ( filetype( $dir . '/' . $object ) == "dir" ) {
+                                       wfRecursiveRemoveDir( $dir . '/' . $object );
+                               } else {
+                                       unlink( $dir . '/' . $object );
+                               }
+                       }
+               }
+               reset( $objects );
+               rmdir( $dir );
+       }
+}
+
 /**
  * @param $nr Mixed: the number to format
  * @param $acc Integer: the number of digits after the decimal point, default 2
index 56afa92..34d829c 100644 (file)
@@ -201,21 +201,3 @@ function switchToTestResources( $testResourceName, $switchDB = true ) {
        $testUploadPath = getTestUploadPathFromResourceName( $testResourceName );
        $wgUploadPath = $testUploadPath;
 }
-
-function wfRecursiveRemoveDir( $dir ) {
-       // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
-       if ( is_dir( $dir ) ) {
-               $objects = scandir( $dir );
-               foreach ( $objects as $object ) {
-                       if ( $object != "." && $object != ".." ) {
-                               if ( filetype( $dir . '/' . $object ) == "dir" ) {
-                                       wfRecursiveRemoveDir( $dir . '/' . $object );
-                               } else {
-                                       unlink( $dir . '/' . $object );
-                               }
-                       }
-               }
-               reset( $objects );
-               rmdir( $dir );
-       }
-}
\ No newline at end of file