summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-08-27 20:33:27 +0200
committerchris <chris@jalakai.co.uk>2006-08-27 20:33:27 +0200
commitdc2c0e04646a8bbd31f08140918d61d1dda25c2e (patch)
treef419fd1140e9eec5d2bdb7399c82117a5838d116
parent6e0cc83a924bf9b5f90ae80f11ccdcf58ee415a7 (diff)
downloadrpg-dc2c0e04646a8bbd31f08140918d61d1dda25c2e.tar.gz
rpg-dc2c0e04646a8bbd31f08140918d61d1dda25c2e.tar.bz2
update cleanID and wikiFN result caches to support unit testing
- move caches into global scope (they were static in function scope) - add teardown() method to clean_id unit test - to clear its cache darcs-hash:20060827183327-9b6ab-cf9beb2ca6c47142dfaad3117d7c86748a54312c.gz
-rw-r--r--_test/cases/inc/pageutils_clean_id.test.php6
-rw-r--r--inc/pageutils.php15
2 files changed, 19 insertions, 2 deletions
diff --git a/_test/cases/inc/pageutils_clean_id.test.php b/_test/cases/inc/pageutils_clean_id.test.php
index 0b4f51571..9884bbc12 100644
--- a/_test/cases/inc/pageutils_clean_id.test.php
+++ b/_test/cases/inc/pageutils_clean_id.test.php
@@ -4,6 +4,10 @@ require_once DOKU_INC.'inc/pageutils.php';
class init_clean_id_test extends UnitTestCase {
+ function teardown() {
+ global $cache_cleanid;
+ $cache_cleanid = array();
+ }
function test_default(){
// we test multiple cases here
@@ -39,6 +43,8 @@ class init_clean_id_test extends UnitTestCase {
$tests = array();
$tests[] = array('page/page',false,'page:page');
+ $this->teardown();
+
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 02330e2a4..882a6bf56 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -58,6 +58,10 @@ function getID($param='id',$clean=true){
return $id;
}
+// function result cache for cleanID
+global $cache_cleanid;
+$cache_cleanid = array();
+
/**
* Remove unwanted chars from ID
*
@@ -73,7 +77,8 @@ function cleanID($raw_id,$ascii=false){
global $lang;
static $sepcharpat = null;
- static $cache = array();
+ global $cache_cleanid;
+ $cache = & $cache_cleanid;
// check if it's already in the memory cache
if (isset($cache[$raw_id])) {
@@ -140,6 +145,10 @@ function noNS($id) {
}
}
+// function result cache for wikiFN
+global $cache_wikifn;
+$cache_wikifn = array();
+
/**
* returns the full path to the datafile specified by ID and
* optional revision
@@ -151,7 +160,9 @@ function noNS($id) {
function wikiFN($raw_id,$rev='',$clean=true){
global $conf;
- static $cache = array();
+ global $cache_wikifn;
+ $cache = & $cache_wikifn;
+
if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) {
return $cache[$raw_id][$rev];
}