diff options
-rw-r--r-- | inc/common.php | 9 | ||||
-rw-r--r-- | inc/pageutils.php | 21 |
2 files changed, 26 insertions, 4 deletions
diff --git a/inc/common.php b/inc/common.php index 0fdeec63b..6f1948ca5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -687,11 +687,12 @@ function saveWikiText($id,$text,$summary){ $old = saveOldRevision($id); if (empty($text)){ - // remove empty files + // remove empty file @unlink($file); - $mfile=wikiMN($id); - if (file_exists($mfile)) { - @unlink($mfile); + // remove any meta info + $mfiles = metaFiles($id); + foreach ($mfiles as $mfile) { + if (file_exists($mfile)) @unlink($mfile); } $del = true; //autoset summary on deletion diff --git a/inc/pageutils.php b/inc/pageutils.php index e22dc3c86..dea691381 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -152,6 +152,27 @@ function metaFN($id,$ext){ } /** + * returns an array of full paths to all metafiles of a given ID + * + * @author Esther Brunner <esther@kaffeehaus.ch> + */ +function metaFiles($id){ + $name = noNS($id); + $dir = metaFN(getNS($id),''); + $files = array(); + + $dh = @opendir($dir); + if(!$dh) return; + while(($file = readdir($dh)) !== false){ + if(strpos($file,$name.'.') == 0 && !is_dir($dir.$file)) + $files[] = $dir.$file; + } + closedir($dh); + + return $files; +} + +/** * returns the full path to the mediafile specified by ID * * The filename is URL encoded to protect Unicode chars |