From 50602150cdefc713863f182b761885259f3734b7 Mon Sep 17 00:00:00 2001
From: Ben Coburn <btcoburn@silicodon.net>
Date: Mon, 28 Aug 2006 09:12:05 +0200
Subject: [PATCH] init global memory cache arrays

Update to 'add function result caching for cleanID and wikiFN'.
Makes certain that arrays exist for the caches, without checking on each function call.
Properly create multidimensional arrays in wikiFN().

darcs-hash:20060828071205-05dcb-7c8dbdb5ea4e7b73808ec3bd9222df1b837d3a1f.gz
---
 inc/init.php      | 4 ++++
 inc/pageutils.php | 1 +
 2 files changed, 5 insertions(+)

diff --git a/inc/init.php b/inc/init.php
index 354e0de8a..13fb3a4bb 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -23,6 +23,10 @@
   if (!defined('DOKU_E_LEVEL')) { error_reporting(E_ALL ^ E_NOTICE); }
   else { error_reporting(DOKU_E_LEVEL); }
 
+  // init memory caches
+  $cache_wikifn = array();
+  $cache_cleanid = array();
+
   //prepare config array()
   global $conf;
   if (!defined('DOKU_UNITTEST')) {
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 882a6bf56..758d34a9e 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -188,6 +188,7 @@ function wikiFN($raw_id,$rev='',$clean=true){
     }
   }
 
+  if (!isset($cache[$raw_id])) { $cache[$raw_id] = array(); }
   $cache[$raw_id][$rev] = $fn;
   return $fn;
 }
-- 
GitLab