Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

PHP 5.3 parser extension tag hooks compatibility

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


questpc at rambler

Sep 12, 2009, 7:06 AM

Post #1 of 2 (273 views)
Permalink
PHP 5.3 parser extension tag hooks compatibility

Hi!
An user of my extension had reported an error that occurs during calling
registered parser hook under MediaWiki 1.15.1 in PHP 5.3:

function qp_RenderPoll( $input, $argv, &$parser ) {
...
}

Parameter 3 expected to be a reference, value given on line 3243 in
Parser.php

There are two fixed proposed:
http://www.mediawiki.org/wiki/Extension:AccessControl#See_also

a patch to Parser.php. I've checked the revision 55629 and don't see the
patch integrated there.

Patch to the extension:
http://www.mediawiki.org/wiki/Extension_talk:Group_Based_Access_Control#Problem_with_PHP_5.3_.28solved.29

To me it's easy to release the new version, patch is one letter. But,
I've studied other extensions and for example very professional Semantic
MediaWiki also declares third parameter of tag hook method by reference:
static public function doAskHook($querytext, $params, &$parser) {
...
}
maybe not the latest version - v1.4.1, not too old, though. I will check
the latest SMW, too.

What should I do, wait for the Parser.php patch or to use less efficient
passing of large Parser object by value?
Dmitriy

_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


brion at wikimedia

Sep 14, 2009, 11:09 AM

Post #2 of 2 (241 views)
Permalink
Re: PHP 5.3 parser extension tag hooks compatibility [In reply to]

On 9/12/09 7:06 AM, Dmitriy Sintsov wrote:
> To me it's easy to release the new version, patch is one letter. But,
> I've studied other extensions and for example very professional Semantic
> MediaWiki also declares third parameter of tag hook method by reference:
> static public function doAskHook($querytext, $params,&$parser) {

Most of those are old leftovers from PHP 4, which would copy objects
instead of using sane value-reference semantics. These are being cleaned
up in dev work for 1.6 as people are more actively testing with PHP 5.3.0.

References for hook parameters should *only* be used for out-parameters
where the hook needs to be able to return a new value to the caller,
*not* for simply passing objects.

> What should I do, wait for the Parser.php patch or to use less efficient
> passing of large Parser object by value?

Using a PHP reference here is actually less efficient and more error-prone.

Passing objects "by value" in PHP 5 works the same as it does in Java,
Python, etc -- that is, you're actually passing around a reference to
the object... but if you were to, say, assign a different object to the
variable in your function, *that* change would not propagate back to the
caller, as you're passing the reference by value.

Yeah I know, it's confusing. ;) Just stay away from references unless
you're realllllly sure you need em. ;)

-- brion

_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.