From f7fadb9b7e73e2b5a11de5aa9fa4015f661f7a73 Mon Sep 17 00:00:00 2001 From: Ruediger Marwein Date: Tue, 31 May 2022 18:54:47 +0200 Subject: [PATCH] add condition in case the file of the page does not exist. --- action.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/action.php b/action.php index 1413e49..8e0d61d 100644 --- a/action.php +++ b/action.php @@ -33,15 +33,18 @@ class action_plugin_usetheme extends DokuWiki_Action_Plugin { public function _handleConf(Doku_Event $event, $param) { global $ID, $ACT, $conf; $dataFile = wikiFN(cleanID($ID)); - $fp = fopen($dataFile,"r"); - $firstLine = fgets($fp,512); - fclose($fp); - preg_match('/~~USETHEME:(.*?)~~/', $firstLine, $match); - $template = trim($match[1]); - if($template) { - $conf['template'] = $template; + if(is_file($dataFile)) { + $fp = fopen($dataFile,"r"); + $firstLine = fgets($fp,512); + fclose($fp); + preg_match('/~~USETHEME:(.*?)~~/', $firstLine, $match); + $template = trim($match[1]); + if($template) { + $conf['template'] = $template; + } } } + } // vim:ts=4:sw=4: