diff options
Diffstat (limited to 'inc/indexer.php')
-rw-r--r-- | inc/indexer.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/inc/indexer.php b/inc/indexer.php index 714feb4f7..3b4796676 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']); @@ -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', true); + $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', true); - if (($references = p_get_metadata($page, 'relation references', true)) !== 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); |