r112326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112325‎ | r112326 | r112327 >
Date:15:41, 24 February 2012
Author:hashar
Status:ok
Tags:
Comment:
move wfRecursiveRemoveDir to global functions

That useful method was hidden in SeleniumWebSettings. I need it to clean
up test files leakages.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/SeleniumWebSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2616,6 +2616,29 @@
26172617 }
26182618
26192619 /**
 2620+ * Remove a directory and all its content.
 2621+ * Does not hide error.
 2622+ */
 2623+function wfRecursiveRemoveDir( $dir ) {
 2624+ wfDebug( __FUNCTION__ . "( $dir )\n" );
 2625+ // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
 2626+ if ( is_dir( $dir ) ) {
 2627+ $objects = scandir( $dir );
 2628+ foreach ( $objects as $object ) {
 2629+ if ( $object != "." && $object != ".." ) {
 2630+ if ( filetype( $dir . '/' . $object ) == "dir" ) {
 2631+ wfRecursiveRemoveDir( $dir . '/' . $object );
 2632+ } else {
 2633+ unlink( $dir . '/' . $object );
 2634+ }
 2635+ }
 2636+ }
 2637+ reset( $objects );
 2638+ rmdir( $dir );
 2639+ }
 2640+}
 2641+
 2642+/**
26202643 * @param $nr Mixed: the number to format
26212644 * @param $acc Integer: the number of digits after the decimal point, default 2
26222645 * @param $round Boolean: whether or not to round the value, default true
Index: trunk/phase3/includes/SeleniumWebSettings.php
@@ -201,21 +201,3 @@
202202 $testUploadPath = getTestUploadPathFromResourceName( $testResourceName );
203203 $wgUploadPath = $testUploadPath;
204204 }
205 -
206 -function wfRecursiveRemoveDir( $dir ) {
207 - // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
208 - if ( is_dir( $dir ) ) {
209 - $objects = scandir( $dir );
210 - foreach ( $objects as $object ) {
211 - if ( $object != "." && $object != ".." ) {
212 - if ( filetype( $dir . '/' . $object ) == "dir" ) {
213 - wfRecursiveRemoveDir( $dir . '/' . $object );
214 - } else {
215 - unlink( $dir . '/' . $object );
216 - }
217 - }
218 - }
219 - reset( $objects );
220 - rmdir( $dir );
221 - }
222 -}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r112327avoid exif tests file leakage...hashar15:43, 24 February 2012
r112354MFT to REL1_19 fix tests leaking files...hashar20:38, 24 February 2012

Status & tagging log