summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-05-05 21:09:40 +0200
committerMichael Hamann <michael@content-space.de>2013-05-05 21:22:47 +0200
commitb1720e5c647585ac14f86e6080b54c932cac9bee (patch)
treecfaf58f58f483e6e028a59831f635687a98cf1d2 /inc
parent9e64ca0debc28da382754236a849287cd6da737c (diff)
downloadrpg-b1720e5c647585ac14f86e6080b54c932cac9bee.tar.gz
rpg-b1720e5c647585ac14f86e6080b54c932cac9bee.tar.bz2
Indexer: Remove broken and dead readdircache code FS#2771
The code that is removed in this commit has either never been used (listIndexLenghts) or was completely broken (cacheIndexDir) and was introduced in the indexer rewrite in 2010. The idea of the rewrite was to update the readdir cache after every index change instead of on demand. What the code actually did was removing every updated index from the cache as it used a wrong if condition. Simply fixing the condition wouldn't fix the problem as then only updated indexes would be added to the cache and furthermore the rewrite simply ignored the readdircache setting. For now the safest solution seems to be removing the code. It could be added again in a changed form in a future version.
Diffstat (limited to 'inc')
-rw-r--r--inc/indexer.php78
1 files changed, 1 insertions, 77 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index fdb147334..2f3ab25dc 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -1073,8 +1073,6 @@ class Doku_Indexer {
if (isset($conf['fperm']))
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
- if ($suffix !== '')
- $this->cacheIndexDir($idx, $suffix, empty($lines));
return true;
}
@@ -1140,8 +1138,6 @@ class Doku_Indexer {
if (isset($conf['fperm']))
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
- if ($suffix !== '')
- $this->cacheIndexDir($idx, $suffix);
return true;
}
@@ -1169,40 +1165,6 @@ class Doku_Indexer {
}
/**
- * @param string $idx The index file which should be added to the key.
- * @param string $suffix The suffix of the file
- * @param bool $delete Unused
- */
- protected function cacheIndexDir($idx, $suffix, $delete=false) {
- global $conf;
- if ($idx == 'i')
- $cachename = $conf['indexdir'].'/lengths';
- else
- $cachename = $conf['indexdir'].'/'.$idx.'lengths';
- $lengths = @file($cachename.'.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- if ($lengths === false) $lengths = array();
- $old = array_search((string)$suffix, $lengths);
- if (empty($lines)) {
- if ($old === false) return;
- unset($lengths[$old]);
- } else {
- if ($old !== false) return;
- $lengths[] = $suffix;
- sort($lengths);
- }
- $fh = @fopen($cachename.'.tmp', 'w');
- if (!$fh) {
- trigger_error("Failed to write index cache", E_USER_ERROR);
- return;
- }
- @fwrite($fh, implode("\n", $lengths));
- @fclose($fh);
- if (isset($conf['fperm']))
- chmod($cachename.'.tmp', $conf['fperm']);
- io_rename($cachename.'.tmp', $cachename.'.idx');
- }
-
- /**
* Get the list of lengths indexed in the wiki.
*
* Read the index directory or a cache file and returns
@@ -1211,45 +1173,7 @@ class Doku_Indexer {
* @author YoBoY <yoboy.leguesh@gmail.com>
*/
protected function listIndexLengths() {
- global $conf;
- $cachename = $conf['indexdir'].'/lengths';
- clearstatcache();
- if (@file_exists($cachename.'.idx')) {
- $lengths = @file($cachename.'.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- if ($lengths !== false) {
- $idx = array();
- foreach ($lengths as $length)
- $idx[] = (int)$length;
- return $idx;
- }
- }
-
- $dir = @opendir($conf['indexdir']);
- if ($dir === false)
- return array();
- $lengths[] = array();
- while (($f = readdir($dir)) !== false) {
- if (substr($f, 0, 1) == 'i' && substr($f, -4) == '.idx') {
- $i = substr($f, 1, -4);
- if (is_numeric($i))
- $lengths[] = (int)$i;
- }
- }
- closedir($dir);
- sort($lengths);
- // save this in a file
- $fh = @fopen($cachename.'.tmp', 'w');
- if (!$fh) {
- trigger_error("Failed to write index cache", E_USER_ERROR);
- return $lengths;
- }
- @fwrite($fh, implode("\n", $lengths));
- @fclose($fh);
- if (isset($conf['fperm']))
- chmod($cachename.'.tmp', $conf['fperm']);
- io_rename($cachename.'.tmp', $cachename.'.idx');
-
- return $lengths;
+ return idx_listIndexLengths();
}
/**