Skip to content
Snippets Groups Projects
Commit fcaef043 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Merge pull request #1537 from micgro42/wikiFNcachingFix

Fix caching issue in wikiFN
parents 72bdb542 30f3bd15
No related branches found
No related tags found
No related merge requests found
......@@ -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 :
<?php
class wikifn_test extends DokuWikiTest {
function test_cache_cleaning_cleanToUnclean(){
$this->assertEquals(wikiFN('wiki:',null,false),DOKU_TMP_DATA.'pages/wiki/.txt');
$this->assertEquals(wikiFN('wiki:',null,true),DOKU_TMP_DATA.'pages/wiki.txt');
}
function test_cache_cleaning_uncleanToClean(){
$this->assertEquals(wikiFN('wiki:',null,true),DOKU_TMP_DATA.'pages/wiki.txt');
$this->assertEquals(wikiFN('wiki:',null,false),DOKU_TMP_DATA.'pages/wiki/.txt');
}
}
//Setup VIM: ex: et ts=4 :
......@@ -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);
}
......@@ -285,14 +285,15 @@ function wikiFN($raw_id,$rev='',$clean=true){
global $cache_wikifn;
$cache = & $cache_wikifn;
if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) {
return $cache[$raw_id][$rev];
}
$id = $raw_id;
if ($clean) $id = cleanID($id);
$id = str_replace(':','/',$id);
if (isset($cache[$id]) && isset($cache[$id][$rev])) {
return $cache[$id][$rev];
}
if(empty($rev)){
$fn = $conf['datadir'].'/'.utf8_encodeFN($id).'.txt';
}else{
......@@ -310,8 +311,8 @@ function wikiFN($raw_id,$rev='',$clean=true){
}
}
if (!isset($cache[$raw_id])) { $cache[$raw_id] = array(); }
$cache[$raw_id][$rev] = $fn;
if (!isset($cache[$id])) { $cache[$id] = array(); }
$cache[$id][$rev] = $fn;
return $fn;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment