summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorTom N Harris <tnharris@whoopdedo.org>2011-02-25 18:23:47 -0500
committerTom N Harris <tnharris@whoopdedo.org>2011-02-25 18:23:47 -0500
commit1538718db8939adf4ce057f2b7fb6d2eea309757 (patch)
tree070423519cdceb6737b4bcdb0d0f672778abe698 /inc
parent675bf41fb9fe7d43646c3ff2de5a1e701818ed2c (diff)
downloadrpg-1538718db8939adf4ce057f2b7fb6d2eea309757.tar.gz
rpg-1538718db8939adf4ce057f2b7fb6d2eea309757.tar.bz2
Restrict metadata values in indexer to string; skip unnecessary test
Diffstat (limited to 'inc')
-rw-r--r--inc/indexer.php14
1 files changed, 6 insertions, 8 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index 6913dd4e3..fc7813ba1 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -505,10 +505,11 @@ class Doku_Indexer {
* callback function that returns true or false to use a different
* comparison function. The function will be called with the $value being
* searched for as the first argument, and the word in the index as the
- * second argument.
+ * second argument. The function preg_match can be used directly if the
+ * values are regexes.
*
* @param string $key name of the metadata key to look for
- * @param string $value search term to look for
+ * @param string $value search term to look for, must be a string or array of strings
* @param callback $func comparison function
* @return array lists with page names, keys are query values if $value is array
* @author Tom N Harris <tnharris@whoopdedo.org>
@@ -533,9 +534,9 @@ class Doku_Indexer {
}
if (!is_null($func)) {
- foreach ($value_array as &$val) {
+ foreach ($value_array as $val) {
foreach ($words as $i => $word) {
- if (call_user_func_array($func, array(&$val, $word)))
+ if (call_user_func_array($func, array($val, $word)))
$value_ids[$i][] = $val;
}
}
@@ -591,10 +592,7 @@ class Doku_Indexer {
// is an array with page_id => 1, page2_id => 1 etc. so take the keys only
$pages = array_keys($this->_parseTuples($page_idx, $lines[$value_id]));
foreach ($val_list as $val) {
- if (!isset($result[$val]))
- $result[$val] = $pages;
- else
- $result[$val] = array_merge($result[$val], $pages);
+ $result[$val] = array_merge($result[$val], $pages);
}
}
}