[dokuwiki] Re: Question about global $NS in the development version

  • From: Michael Hamann <michael@xxxxxxxxxxxxxxxx>
  • To: dokuwiki <dokuwiki@xxxxxxxxxxxxx>
  • Date: Thu, 06 Jan 2011 22:54:15 +0100

Hi,

Excerpts from Guillaume Turri's message of 2011-01-06 09:05:33 +0100:
[...]
> My plugin will then need to call p_get_first_heading('ns2:page2'). This
> function will then call p_get_metadata, which will use p_render_metadata.
> There, the value of the global $ID (which is currently 'ns1:page1') is
> changed to 'ns2:page2'. This page is parsed, and $ID is restored.
> My issue is that, while $ID is ok, $NS will still be 'ns1', and thus, the
> call to my plugin when parsing ns2:page2 page will use a wrong value (then,
> it's handle() will generate wrong data, and since this data will be cached,
> the next time I'll request ns2:page2, it will display wrong results).

This applies to all rendering functions, they all set $ID but nothing
else.

> Of course, I could solve my problem by not relying on $NS, and by computing
> it from $ID. But I wonder if it is not something that could/should be change
> in Dokuwiki.

I don't think this should be changed in DokuWiki. $NS is only set in
doku.php and ajax.php that means it will be missing in other contexts,
too (e.g. when the rendered page is request over XML-RPC). Btw. the
exactly same problem you are experiencing should have occurred in the
sidebar of older versions, too. My suggestion is to rather completely
remove $NS (with prior deprecation) as it is only used in very few
places and not documented at http://www.dokuwiki.org/devel:environment.
We should rather document that the only information that should be used
during parsing/rendering is $ID.

> More precisely, a solution would be to change the global $NS at the same
> time as $ID (see patch attached to this mail).

I'm against this as there a problably a lot of places where $NS needs to
be changed.

Regards,
Michael
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: