diff options
-rw-r--r-- | inc/common.php | 4 | ||||
-rw-r--r-- | inc/io.php | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/inc/common.php b/inc/common.php index 482bb1e2d..47defb8af 100644 --- a/inc/common.php +++ b/inc/common.php @@ -487,7 +487,7 @@ function parsedWiki($id,$rev='',$excuse=true){ //ensure $id is in global $ID (needed for parsing) global $ID; $ID = $id; - + if($rev){ if(@file_exists($file)){ $ret = parse(io_readFile($file)); @@ -689,6 +689,8 @@ function saveWikiText($id,$text,$summary){ $del = true; //autoset summary on deletion if(empty($summary)) $summary = $lang['deleted']; + //remove empty namespaces + io_sweepNS($id); }else{ // save file (datadir is created in io_saveFile) io_saveFile($file,$text); diff --git a/inc/io.php b/inc/io.php index d59efbc78..ceb747ed9 100644 --- a/inc/io.php +++ b/inc/io.php @@ -57,6 +57,25 @@ function io_cacheParse($file){ } /** + * Removes empty directories + * + * @todo use safemode hack + * @author Andreas Gohr <andi@splitbrain.org> + */ +function io_sweepNS($id){ + global $conf; + + //scan all namespaces + while(($id = getNS($id)) !== false){ + $dir = $conf['datadir'].'/'.str_replace(':','/',$id); + $dir = utf8_encodeFN($dir); + + //try to delete dir else return + if(!@rmdir($dir)) return; + } +} + +/** * Returns content of $file as cleaned string. * * Uses gzip if extension is .gz |