From d0d6fe1be56ef474d844b3556af7ba2a5961d798 Mon Sep 17 00:00:00 2001
From: Tom N Harris <tnharris@whoopdedo.org>
Date: Tue, 22 Feb 2011 02:53:20 -0500
Subject: [PATCH] Indexer version tag should include plugin names

---
 inc/indexer.php | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/inc/indexer.php b/inc/indexer.php
index 1809b1c8f..bcda2a9b9 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -50,19 +50,33 @@ define('IDX_ASIAN', '(?:'.IDX_ASIAN1.'|'.IDX_ASIAN2.'|'.IDX_ASIAN3.')');
  * Version of the indexer taking into consideration the external tokenizer.
  * The indexer is only compatible with data written by the same version.
  *
+ * Triggers INDEXER_VERSION_GET
+ * Plugins that modify what gets indexed should hook this event and
+ * add their version info to the event data like so:
+ *     $data[$plugin_name] = $plugin_version;
+ *
  * @author Tom N Harris <tnharris@whoopdedo.org>
  * @author Michael Hamann <michael@content-space.de>
  */
 function idx_get_version(){
-    global $conf;
-    if($conf['external_tokenizer'])
-        $version = INDEXER_VERSION . '+' . trim($conf['tokenizer_cmd']);
-    else
-        $version = INDEXER_VERSION;
-
-    $data = array($version);
-    trigger_event('INDEXER_VERSION_GET', $data, null, false);
-    return implode('+', $data);
+    static $indexer_version = null;
+    if ($indexer_version == null) {
+        global $conf;
+        if($conf['external_tokenizer'])
+            $version = INDEXER_VERSION . '+' . trim($conf['tokenizer_cmd']);
+        else
+            $version = INDEXER_VERSION;
+
+        // DokuWiki version is included for the convenience of plugins
+        $data = array('dokuwiki'=>$version);
+        trigger_event('INDEXER_VERSION_GET', $data, null, false);
+        unset($data['dokuwiki']); // this needs to be first
+        ksort($data);
+        foreach ($data as $plugin=>$vers)
+            $version .= '+'.$plugin.'='.$vers;
+        $indexer_version = $version;
+    }
+    return $indexer_version;
 }
 
 /**
-- 
GitLab