From: x2003bruneau Date: Sun, 28 Jan 2007 17:31:04 +0000 (+0000) Subject: Do not cache empty wiki pages X-Git-Tag: xorg/0.9.13~50 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=3da341b61df6be6712e4db93ebfda4d774012fd3;p=platal.git Do not cache empty wiki pages git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1421 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/htdocs/xnet.php b/htdocs/xnet.php index 4528800..4aa981b 100644 --- a/htdocs/xnet.php +++ b/htdocs/xnet.php @@ -20,7 +20,7 @@ ***************************************************************************/ $GLOBALS['IS_XNET_SITE'] = true; -global $platal; +global $platal, $globals, $page; require_once dirname(__FILE__).'/../include/xnet.inc.php'; diff --git a/htdocs/xorg.php b/htdocs/xorg.php index 7b6a810..717c3b5 100644 --- a/htdocs/xorg.php +++ b/htdocs/xorg.php @@ -20,6 +20,7 @@ ***************************************************************************/ require_once dirname(__FILE__).'/../include/xorg.inc.php'; +global $globals, $platal, $page; if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) { diff --git a/include/wiki/engine.php b/include/wiki/engine.php index 1ac5511..8455e44 100644 --- a/include/wiki/engine.php +++ b/include/wiki/engine.php @@ -64,7 +64,9 @@ $wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl'; $cache_exists = file_exists($wiki_cache); if (Env::v('action') || !$cache_exists) { - @unlink($wiki_cache); + if ($cache_exists) { + unlink($wiki_cache); + } // we leave pmwiki do whatever it wants and store everything ob_start(); @@ -76,15 +78,22 @@ if (Env::v('action') || !$cache_exists) { $j = strpos($wikiAll, "", $i); } +$wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n)); + if (Env::v('action')) { $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); $wikiAll = substr($wikiAll, $j); } else { - if (!$cache_exists) { + if (!$cache_exists && $wiki_exists) { $wikiAll = substr($wikiAll, $j); wiki_putfile($wiki_cache, $wikiAll); - } else { + } elseif ($cache_exists) { $wikiAll = file_get_contents($wiki_cache); + } elseif (S::has_perms()) { + $wikiAll = "

La page de wiki $n n'existe pas. " + . "Il te suffit de l'éditer

"; + } else { + $page->changeTpl('core/404.tpl'); } } @@ -98,7 +107,7 @@ $page->assign('canedit', wiki_may_have_perms($perms[1])); $page->assign('has_perms', wiki_may_have_perms('admin')); $page->assign('wikipage', str_replace('.', '/', $n)); -if ($perms[1] == 'admin' && !Env::v('action')) { +if ($perms[1] == 'admin' && !Env::v('action') && $wiki_exists) { $page->assign('pmwiki_cache', $wiki_cache); } else { $page->assign('pmwiki', $wikiAll);