[pmwiki-devel] $zz in defintion for (:title ... :)

Patrick R. Michaud pmichaud at pobox.com
Tue Oct 31 09:24:33 CST 2006


On Tue, Oct 31, 2006 at 02:01:13AM -0500, Stirling Westrup wrote:
> I was just reading through the PmWiki code trying to figure out how to
> do something, and I noticed the definition of the (:title ... :)
> directive goes like this:
> 
> ## (:title:)
> Markup('title','>&',
>   '/\\(:title\\s(.*?):\\)/ei',
>   "PZZ(PCache(\$pagename,
>          \$zz=array('title' => SetProperty(\$pagename, 'title',
> PSS('$1')))))");
> 
> Can anyone tell me why that \$zz is in there?

At one point the PCache() function was defined such that
its second paramter was being passed by reference, instead
of being passed by value.  As a result, the second argument
to PCache() had to be a true variable and not just a
temporary value.

So, the $zz= trick assigns the array to a temporary variable,
and passes that variable by reference.

However, I've since found out that PHP uses copy-on-write
for arrays passed as parameters, so there's little need
for PCache() to be receiving its second argument by reference.
So, this little hack will likely be going away soon.

Pm



More information about the pmwiki-devel mailing list