From 30f3bd15e697a50e85567a6d82d4f531f9b6c782 Mon Sep 17 00:00:00 2001 From: Michael Grosse <grosse@cosmocode.de> Date: Wed, 20 Apr 2016 12:44:52 +0200 Subject: [PATCH] Do not cache cleanID for $ascii == true Caching must differentiate between a call with $ascii == true and a call without that parameter. Since calling that function with $ascii == true rare, we simply do not cache that case. --- _test/tests/inc/pageutils_clean_id.test.php | 10 ++++++++++ inc/pageutils.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/_test/tests/inc/pageutils_clean_id.test.php b/_test/tests/inc/pageutils_clean_id.test.php index f67109ba3..25d0a9f69 100644 --- a/_test/tests/inc/pageutils_clean_id.test.php +++ b/_test/tests/inc/pageutils_clean_id.test.php @@ -158,5 +158,15 @@ class init_clean_id_test extends DokuWikiTest { } } + function test_caching_ascii() { + global $conf; + $conf['deaccent'] = 0; + $this->assertEquals('pà ge', cleanID('pà ge',false)); + $this->assertEquals('page', cleanID('pà ge',true)); + + $this->assertEquals('page', cleanID('pagĖ',true)); + $this->assertEquals('pagė', cleanID('pagĖ',false)); + } + } //Setup VIM: ex: et ts=4 : diff --git a/inc/pageutils.php b/inc/pageutils.php index 6498fca40..b7e09af5b 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -110,7 +110,7 @@ function cleanID($raw_id,$ascii=false){ $cache = & $cache_cleanid; // check if it's already in the memory cache - if (isset($cache[(string)$raw_id])) { + if (!$ascii && isset($cache[(string)$raw_id])) { return $cache[(string)$raw_id]; } @@ -143,7 +143,7 @@ function cleanID($raw_id,$ascii=false){ $id = preg_replace('#:[:\._\-]+#',':',$id); $id = preg_replace('#[:\._\-]+:#',':',$id); - $cache[(string)$raw_id] = $id; + if (!$ascii) $cache[(string)$raw_id] = $id; return($id); } -- GitLab