summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2008-08-13 22:06:14 +0200
committerMichael Klier <chi@chimeric.de>2008-08-13 22:06:14 +0200
commit593bf8f6e49cbf0437d75edaa8a468d8bbfe6911 (patch)
treeb169d3a2fbb086230b7dbfbdefdb22b1753a6682 /lib/exe
parent94806c6f093ed94d70c5720d2ea1f1747440087f (diff)
downloadrpg-593bf8f6e49cbf0437d75edaa8a468d8bbfe6911.tar.gz
rpg-593bf8f6e49cbf0437d75edaa8a468d8bbfe6911.tar.bz2
XMLRPC: run indexer on putPage()
darcs-hash:20080813200614-23886-ad320ca14e120d8206ee5ffdfb4ac087e0aa6929.gz
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/xmlrpc.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php
index 256cd61fc..eaa68c76c 100644
--- a/lib/exe/xmlrpc.php
+++ b/lib/exe/xmlrpc.php
@@ -6,14 +6,15 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
require_once(DOKU_INC.'inc/init.php');
+require_once(DOKU_INC.'inc/common.php');
+require_once(DOKU_INC.'inc/auth.php');
+session_write_close(); //close session
if(!$conf['xmlrpc']) {
die('XML-RPC server not enabled.');
+ // FIXME check for groups allowed
}
-require_once(DOKU_INC.'inc/common.php');
-require_once(DOKU_INC.'inc/auth.php');
-session_write_close(); //close session
require_once(DOKU_INC.'inc/IXR_Library.php');
@@ -252,6 +253,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
function putPage($id, $text, $params) {
global $TEXT;
global $lang;
+ global $conf;
$id = cleanID($id);
$TEXT = trim($text);
@@ -292,6 +294,31 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
unlock($id);
+ // run the indexer if page wasn't indexed yet
+ if(!@file_exists(metaFN($id, '.indexed'))) {
+ // try to aquire a lock
+ $lock = $conf['lockdir'].'/_indexer.lock';
+ while(!@mkdir($lock,$conf['dmode'])){
+ usleep(50);
+ if(time()-@filemtime($lock) > 60*5){
+ // looks like a stale lock - remove it
+ @rmdir($lock);
+ }else{
+ return false;
+ }
+ }
+ if($conf['dperm']) chmod($lock, $conf['dperm']);
+
+ require_once(DOKU_INC.'inc/indexer.php');
+
+ // do the work
+ idx_addPage($id);
+
+ // we're finished - save and free lock
+ io_saveFile(metaFN($id,'.indexed'),INDEXER_VERSION);
+ @rmdir($lock);
+ }
+
return 0;
}