From e1f3d9e1aa287c644fee854d1fddcfb5de4e31f5 Mon Sep 17 00:00:00 2001 From: Esther Brunner Date: Tue, 16 Aug 2005 20:22:01 +0200 Subject: delete meta files on page deletion darcs-hash:20050816182201-283c4-75638010c1f75cfb7e905bca5647253084e69323.gz --- inc/common.php | 9 +++++---- 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 @@ -151,6 +151,27 @@ function metaFN($id,$ext){ return $fn; } +/** + * returns an array of full paths to all metafiles of a given ID + * + * @author Esther Brunner + */ +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 * -- cgit v1.2.3