Skip to content
Snippets Groups Projects
Commit 53d6ccfe authored by andi's avatar andi
Browse files

remove empty namespaces on page deletion

darcs-hash:20050320182150-9977f-34610c4d2cd518c1de891e098859e1aaa74355a8.gz
parent 81aafed4
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -56,6 +56,25 @@ function io_cacheParse($file){
return $parsed;
}
/**
* 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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment