summaryrefslogtreecommitdiff
path: root/inc/indexer.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/indexer.php')
-rw-r--r--inc/indexer.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index 1db966656..1f0094876 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -489,6 +489,9 @@ class Doku_Indexer {
foreach ($result as $word => $res) {
$final[$word] = array();
foreach ($res as $wid) {
+ // handle the case when ($ixid < count($index)) has been false
+ // and thus $docs[$wid] hasn't been set.
+ if (!isset($docs[$wid])) continue;
$hits = &$docs[$wid];
foreach ($hits as $hitkey => $hitcnt) {
// make sure the document still exists
@@ -857,6 +860,8 @@ class Doku_Indexer {
$fh = @fopen($fn.'.tmp', 'w');
if (!$fh) return false;
fwrite($fh, join("\n", $lines));
+ if (!empty($lines))
+ fwrite($fh, "\n");
fclose($fh);
if (isset($conf['fperm']))
chmod($fn.'.tmp', $conf['fperm']);
@@ -904,7 +909,7 @@ class Doku_Indexer {
$line .= "\n";
$fn = $conf['indexdir'].'/'.$idx.$suffix;
$fh = @fopen($fn.'.tmp', 'w');
- if (!fh) return false;
+ if (!$fh) return false;
$ih = @fopen($fn.'.idx', 'r');
if ($ih) {
$ln = -1;
@@ -1161,13 +1166,14 @@ function & idx_get_stopwords() {
*
* @param string $page name of the page to index
* @param boolean $verbose print status messages
+ * @param boolean $force force reindexing even when the index is up to date
* @return boolean the function completed successfully
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
-function idx_addPage($page, $verbose=false) {
+function idx_addPage($page, $verbose=false, $force=false) {
// check if indexing needed
$idxtag = metaFN($page,'.indexed');
- if(@file_exists($idxtag)){
+ if(!$force && @file_exists($idxtag)){
if(trim(io_readFile($idxtag)) == idx_get_version()){
$last = @filemtime($idxtag);
if($last > @filemtime(wikiFN($page))){
@@ -1191,7 +1197,7 @@ function idx_addPage($page, $verbose=false) {
@unlink($idxtag);
return $result;
}
- $indexenabled = p_get_metadata($page, 'internal index', false);
+ $indexenabled = p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED);
if ($indexenabled === false) {
$result = false;
if (@file_exists($idxtag)) {
@@ -1209,8 +1215,8 @@ function idx_addPage($page, $verbose=false) {
$body = '';
$metadata = array();
- $metadata['title'] = p_get_metadata($page, 'title', false);
- if (($references = p_get_metadata($page, 'relation references', false)) !== null)
+ $metadata['title'] = p_get_metadata($page, 'title', METADATA_RENDER_UNLIMITED);
+ if (($references = p_get_metadata($page, 'relation references', METADATA_RENDER_UNLIMITED)) !== null)
$metadata['relation_references'] = array_keys($references);
else
$metadata['relation_references'] = array();
@@ -1317,7 +1323,7 @@ function idx_listIndexLengths() {
$dir = @opendir($conf['indexdir']);
if ($dir === false)
return array();
- $idx[] = array();
+ $idx = array();
while (($f = readdir($dir)) !== false) {
if (substr($f, 0, 1) == 'i' && substr($f, -4) == '.idx') {
$i = substr($f, 1, -4);