From 33a148e0f7688489ba9900abb450364586a68cdb Mon Sep 17 00:00:00 2001
From: Tom N Harris <tnharris@whoopdedo.org>
Date: Tue, 26 Feb 2008 02:19:40 +0100
Subject: [PATCH] INDEXER_TASKS_RUN event for index-time hooks

The event INDEXER_TASKS_RUN is fired by lib/exe/indexer.php when a page is viewed. Plugins should only hook BEFORE the event if it is important for the task to be run as often as possible. Otherwise, hook AFTER the even to be run only when other tasks have completed.

Plugin authors must call stopPropagation() and preventDefault() if any work is done. If your plugin does nothing, then you must allow the event to continue. Not following these rules may cause DokuWiki to exceed the PHP execution time limit.

darcs-hash:20080226011940-6942e-09291b73bab84a2c4445b1d1c4de8b3bba743243.gz
---
 lib/exe/indexer.php | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index 8f2205fe5..be5eed897 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -27,11 +27,21 @@ if(@ignore_user_abort() && !$conf['broken_iua']){
     $defer = true;
 }
 
+$ID = cleanID($_REQUEST['id']);
+
 // Catch any possible output (e.g. errors)
 if(!$_REQUEST['debug']) ob_start();
 
 // run one of the jobs
-runIndexer() or metaUpdate() or runSitemapper() or runTrimRecentChanges();
+$tmp = array();
+$evt = new Doku_Event('INDEXER_TASKS_RUN', $tmp);
+if ($evt->advise_before()) {
+  runIndexer() or 
+  metaUpdate() or 
+  runSitemapper() or 
+  runTrimRecentChanges() or 
+  $evt->advise_after();
+}
 if($defer) sendGIF();
 
 if(!$_REQUEST['debug']) ob_end_clean();
@@ -120,6 +130,7 @@ function runTrimRecentChanges() {
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function runIndexer(){
+    global $ID;
     global $conf;
     print "runIndexer(): started".NL;
 
@@ -135,7 +146,6 @@ function runIndexer(){
         trigger_event('TEMPORARY_INDEX_UPGRADE_EVENT', $tmp);
     }
 
-    $ID = cleanID($_REQUEST['id']);
     if(!$ID) return false;
 
     // check if indexing needed
@@ -188,9 +198,9 @@ function runIndexer(){
  * gain their data when viewed for the first time.
  */
 function metaUpdate(){
+    global $ID;
     print "metaUpdate(): started".NL;
 
-    $ID = cleanID($_REQUEST['id']);
     if(!$ID) return false;
     $file = metaFN($ID, '.meta');
     echo "meta file: $file".NL;
-- 
GitLab