diff --git a/inc/pageutils.php b/inc/pageutils.php
index 3bb10883f4062108763da72a2a5a746e8b742a1f..ef82eebcd897a386337f379cb92bcfe056824cd0 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -645,6 +645,7 @@ function utf8_decodeFN($file){
  * @return string|false the full page id of the found page, false if any
  */
 function page_findnearest($page){
+    if (!$page) return false;
     global $ID;
 
     $ns = $ID;
diff --git a/inc/template.php b/inc/template.php
index 0d96be214b67544351d7a2eba3917fbaf388678d..4af35cc2bff233238124af4c9a329a18cf01b30c 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1471,11 +1471,10 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap =
  * template
  */
 function tpl_include_page($pageid, $print = true, $propagate = false) {
-    global $ID;
-    global $TOC;
-
+    if (!$pageid) return false;
     if ($propagate) $pageid = page_findnearest($pageid);
 
+    global $TOC;
     $oldtoc = $TOC;
     $html   = p_wiki_xhtml($pageid, '', false);
     $TOC    = $oldtoc;