Page MenuHomePhabricator

Lazy loading and passing by reference
Closed, ResolvedPublic

Description

Author: Keisial

Description:
StubParser

I have problems in the passing of parameters as value or reference in PHP 5.3, interferring with the lazy loading.
Seems that it is choosing to pass it as value looking at the prototype. But when the object is still a Stub, the protoype is not available and pass-by-value is wrongly chosen.
I see it on the second argument of Parser::parse() but it may also be present on other places.

If you're lucky, you get a Warning at the call_user_func_array() on line 58 of StubObject.php

Else, you can get the obscure: Fatal error: Call to a member function getCacheTime() on a non-object in includes/Article.php on line 3387
($parserOutput was not a parser object because $this->mTitle at line 3383 is passed by value)

If pass-by-reference is specified on the call, it is rightly done, in the example above, it'd be changing it to:
$parserOutput = $wgParser->parse( $text, &$this->mTitle, $popts, true, true, $this->getRevIdFetched() );

So changing all second parameter of $wgParser->parse to be prepended by an ampersand (eg $wgTitle -> &$wgTitle) anywhere $wgParser can be an Stub is a fix. But quite weak.

The other option is to have the prototype available at the stub. I have created a StubParser with a dummy parse() function for that.

Finally, there's another option which is deciding that it's a php bug and complaining to them. After all, Mediawiki is "selected in a new effort by the PHP QA Team to make sure that the project still works with PHP versions to-be-released" so they shouldn't be breaking it ;)


Version: 1.13.x
Severity: normal

Attached:

Details

Reference
bz15854

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:17 PM
bzimport set Reference to bz15854.
bzimport added a subscriber: Unknown Object (MLST).

Note: I fixed this issue on 1.14alpha in r38995 (tested in PHP 5.3.0alpha1 and 2).

Keisial wrote:

I confirm r38995 is another working fix.

uwe wrote:

*** Bug 16505 has been marked as a duplicate of this bug. ***

  • Bug 17407 has been marked as a duplicate of this bug. ***