[dokuwiki] Re: Error in current devel Release?
- From: Christopher Smith <chris@xxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Fri, 27 Jun 2008 10:26:20 +0100
On 27 Jun 2008, at 09:59, Andreas Gohr wrote:
The problem is introduced by the new INIT event. To make that event
work the load order of includes had to to be changed. The problem
occurs when plugins load DokuWiki includes on their own. The simplest
solution is to make those plugins to load the includes in theri
constructor, not in the head of the file.
But because this might break with a bigger number of plugins we might
need to come up with a better solution.
I think Chris and Michael wanted to write about it as well...
The recently added DOKUWIKI_INIT event causes action plugins to be
loaded earlier than previously. If the action plugin includes/
requires other parts of DokuWiki immediately then its possible those
parts are expecting constants/variables to be initialized when they
aren't initialised.
For plugin writers:
By usage convention, its typical to put all the other files a script
depends on (i.e. needs to include/require) at the top of the file.
This isn't necessary and really in the case of plugins is probably not
desirable - a plugin file is loaded often, but the plugin itself may
not be called on to do anything anywhere near as frequently.
The solution to this issue is to make any includes/requires (that rely
on DW being initialized) load as late as possible. Actually putting
them in the constructor is not the solution(*) as the plugin
constructor is called when the plugin is loaded.
Andi, if the INIT event is to go ahead there is no other solution. As
I recall, this was the objection when something similar was mentioned
before.
Basically, if the INIT event is to fly, then any action plugin that
uses DW configuration or other constants will need to be modified to
ensure that it does not refer to those things in inline code, in the
constructor or in the register() function. Basically, all that
"stuff" needs to be moved to the event handling code. As I mentioned
above, this is good practice. The constructor (if present) and the
register() function should be as simple as possible as these are
executed for every DW page where as the events themselves are
dependent on the particular execution track and may or may not be
triggered.
- Chris
(*) it worked for "openid" because the issue was not in the plugin
class itself, but in a secondary file and class.
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- References:
- [dokuwiki] Error in current devel Release?
- From: Gerry Weißbach
- [dokuwiki] Re: Error in current devel Release?
- From: Gerry Weißbach
- [dokuwiki] Re: Error in current devel Release?
- From: Andreas Gohr
Other related posts:
- » [dokuwiki] Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
- » [dokuwiki] Re: Error in current devel Release?
The problem is introduced by the new INIT event. To make that event work the load order of includes had to to be changed. The problem occurs when plugins load DokuWiki includes on their own. The simplest solution is to make those plugins to load the includes in theri constructor, not in the head of the file. But because this might break with a bigger number of plugins we might need to come up with a better solution. I think Chris and Michael wanted to write about it as well...
- [dokuwiki] Error in current devel Release?
- From: Gerry Weißbach
- [dokuwiki] Re: Error in current devel Release?
- From: Gerry Weißbach
- [dokuwiki] Re: Error in current devel Release?
- From: Andreas Gohr