-
2013-01-12
gturri
Some code relies on the current working directory being the root of the DW filesystem (ie: the directory where we can find eg the file doku.php).
For example, by default, $conf['savedir'] is set to "./data".
However when we're doing an xml-rpc query, it becomes lib/exe.It can be an issue in particular with the method getPageHTML
Here is a way to observe this bug, using the nspages plugin:
* create a wiki with the page ns1:page and with the raw wiki text "<nspages>"
* observe this page is a browser: you will have a link to the page itself
* query getPageHTML on this page: you will get the message "this namespace doesn't exist: ns1" [1]
A solution would be to the following patch:
diff --git a/inc/RemoteAPICore.php b/inc/RemoteAPICore.php
index 529ba59..3f0583f 100644
--- a/inc/RemoteAPICore.php
+++ b/inc/RemoteAPICore.php
@@ -229,6 +229,7 @@ class RemoteAPICore {
* Return a wiki page rendered to html
*/
function htmlPage($id,$rev=''){
+ chdir('../../'); //Go from lib/exe to the root, to let code relying on pwd work still fine
$id = $this->resolvePageId($id);
if(auth_quickaclcheck($id) < AUTH_R
I would gladly make a pull request, but I'm not sure it's the best solution (eg: it could be more relevant to do it in lib/exe/xmlrpc)
[1]: the plugin fails when it tests " if(@opendir($conf['savedir'].'/pages/'.$data['wantedDir']) === false || !$data['safe']) ", because $conf['savedir'] is wrong in this xml-rpc context
-
2013-01-18
dominik
The problem here is that $conf['savedir'] isn't a full path.
in this case just use $conf['datadir'].
The $conf['datadir'] points to the pages folder with a full path.
IMHO the $conf['savedir'] variable should also be prepared as full path, but this may has other side effects.
-
2013-01-18
gturri
Indeed, using $conf['datadir'] or making $conf['savedir'] might be a solution here.
However, changing the code of a plugin isn't always an option. Changing the current directory would be a more general solution.
-
2013-01-19
Michitux
There should be no code which relies on the working directory. This code also won't work in other places like the indexer or the JS/CSS generation (might not concern too many plugins). If the savedir depends on the working directory the indexer won't work, too.
-
2013-01-20
gturri
Then I guess I'll just fix my nspages plugin, and we can close this bug.
Thanks for those explanations!