[dokuwiki] Re: Multiple parser instances and PARSER_WIKITEXT_PREPROCESS

  • From: TNHarris <telliamed@xxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 29 Dec 2010 17:55:40 -0500

On 12/29/2010 07:11 AM, Christopher Smith wrote:


No, since PHP5, objects are always passed by reference, the '&'
operator is redundant and the 'clone' keyword is required to copy an
object. As DokuWiki now requires PHP5, the code should probably be
updated to remove them.

I can't think of any specific reason why the call to
PARSER_WIKITEXT_PREPROCESS event is in that particular place (I think
it was me that placed it there). If there are advantages to moving
it before instantiation of the parser and its not likely to break
anything (I don't think it will), I don't see why it can't be moved.

You're right, of course. I was drinking the wrong kool-aid when I wrote that email.

I doubt there's any disadvantage to calling the event hook before creating the Doku_Parser object. But the reference issue remains if a syntax plugin creates a parser in the handle method. So addMode should clone the $Mode object. The alternative is not to set $Mode->Lexer, but that would break too many other functions.

Most modes only have the lexer reference and an array of allowed modes. A few, such as acronym, load a config array and build a regexp. In many cases I think these variables could be class members. It's too bad PHP doesn't allow -> notation on static member variables. But if there aren't any plugins trying to use the parser modes directly, then the change won't be too difficult. The formatting array, for example, is read-only and would benefit from being static.

--
- tom
telliamed@xxxxxxxxxxxxx
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: