Skip to content
Snippets Groups Projects
Commit a23ac4d7 authored by Michael Hamann's avatar Michael Hamann
Browse files

Indexer: Check for deleted pages first FS#2469

This move the check if the page doesn't exist anymore but is still in
the index before the check if the index needs to be updated as otherwise
deleted pages won't be deleted from the index.
parent d0caa564
No related branches found
No related tags found
No related merge requests found
...@@ -1174,18 +1174,8 @@ function & idx_get_stopwords() { ...@@ -1174,18 +1174,8 @@ function & idx_get_stopwords() {
* @author Tom N Harris <tnharris@whoopdedo.org> * @author Tom N Harris <tnharris@whoopdedo.org>
*/ */
function idx_addPage($page, $verbose=false, $force=false) { function idx_addPage($page, $verbose=false, $force=false) {
// check if indexing needed
$idxtag = metaFN($page,'.indexed'); $idxtag = metaFN($page,'.indexed');
if(!$force && @file_exists($idxtag)){ // check if page was deleted but is still in the index
if(trim(io_readFile($idxtag)) == idx_get_version()){
$last = @filemtime($idxtag);
if($last > @filemtime(wikiFN($page))){
if ($verbose) print("Indexer: index for $page up to date".DOKU_LF);
return false;
}
}
}
if (!page_exists($page)) { if (!page_exists($page)) {
if (!@file_exists($idxtag)) { if (!@file_exists($idxtag)) {
if ($verbose) print("Indexer: $page does not exist, ignoring".DOKU_LF); if ($verbose) print("Indexer: $page does not exist, ignoring".DOKU_LF);
...@@ -1200,6 +1190,18 @@ function idx_addPage($page, $verbose=false, $force=false) { ...@@ -1200,6 +1190,18 @@ function idx_addPage($page, $verbose=false, $force=false) {
@unlink($idxtag); @unlink($idxtag);
return $result; return $result;
} }
// check if indexing needed
if(!$force && @file_exists($idxtag)){
if(trim(io_readFile($idxtag)) == idx_get_version()){
$last = @filemtime($idxtag);
if($last > @filemtime(wikiFN($page))){
if ($verbose) print("Indexer: index for $page up to date".DOKU_LF);
return false;
}
}
}
$indexenabled = p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED); $indexenabled = p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED);
if ($indexenabled === false) { if ($indexenabled === false) {
$result = false; $result = false;
......
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