Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/97555


Change subject: Use wfMkdirParents() and wfRecursiveRemoveDir() rather than DIY
......................................................................

Use wfMkdirParents() and wfRecursiveRemoveDir() rather than DIY

Change-Id: I5dfa31a9aa071fdfe28d3a20a5f71adcf3ebcc7f
---
M DPLMain.php
1 file changed, 3 insertions(+), 29 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DynamicPageList 
refs/changes/55/97555/1

diff --git a/DPLMain.php b/DPLMain.php
index 7cfe52e..ed82393 100644
--- a/DPLMain.php
+++ b/DPLMain.php
@@ -2844,12 +2844,12 @@
 
                if ($DPLCache!='') {
                        if (!is_writeable($cacheFile)) {
-                               self::mkdirr(dirname($cacheFile));
+                               wfMkdirParents( dirname( $cacheFile ) );
                        }
                        else if (($bDPLRefresh  || 
$wgRequest->getVal('action','view')=='submit') && strpos($DPLCache,'/')>0 &&  
strpos($DPLCache,'..')===false) {
                                // if the cache file contains a path and the 
user requested a refesh (or saved the file) we delete all brothers
-                               self::rmdirr(dirname($cacheFile));
-                               mkdir(dirname($cacheFile));
+                               wfRecursiveRemoveDir( dirname( $cacheFile ) );
+                               wfMkdirParents( dirname( $cacheFile ) );
                        }
                        $cacheTimeStamp = self::prettyTimeStamp(date('YmdHis'));
                        $cFile = fopen($cacheFile,'w');
@@ -3034,32 +3034,6 @@
                if ($t<2*86400) return "1 day";
            return floor($t/86400). ' days';
     }
-
-       private static function rmdirr($dirname) {
-               if (!file_exists($dirname)) return false; 
-               if (is_file($dirname) || is_link($dirname)) return 
unlink($dirname); 
-               $dir = dir($dirname); 
-               while (false !== $entry = $dir->read()) { 
-                       if ($entry == '.' || $entry == '..') continue; 
-                       self::rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); 
-               }
-               $dir->close(); 
-               return rmdir($dirname); 
-       }
-
-       private static function mkdirr($pathname) {
-               if (is_dir($pathname) || empty($pathname)) return true; 
-               $pathname = str_replace(array('/', ''), DIRECTORY_SEPARATOR, 
$pathname); 
-               if (is_file($pathname)) { 
-                       trigger_error('mkdirr() File exists', E_USER_WARNING); 
-                       return false; 
-               } 
-               $next_pathname = substr($pathname, 0, strrpos($pathname, 
DIRECTORY_SEPARATOR)); 
-               if (self::mkdirr($next_pathname)) { 
-                       if (!file_exists($pathname)) return mkdir($pathname); 
-               } 
-               return  false; 
-       }       
        
        private static function resolveUrlArg($input,$arg) {
                global $wgRequest;

-- 
To view, visit https://gerrit.wikimedia.org/r/97555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5dfa31a9aa071fdfe28d3a20a5f71adcf3ebcc7f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DynamicPageList
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to