Last modified: 2014-05-30 17:26:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T67932, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 65932 - Validator/ParamParser broken on 5.3 due to autoloader
Validator/ParamParser broken on 5.3 due to autoloader
Status: RESOLVED WORKSFORME
Product: MediaWiki extensions
Classification: Unclassified
Validator (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-05-30 05:17 UTC by Daniel Friesen
Modified: 2014-05-30 17:26 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Friesen 2014-05-30 05:17:23 UTC
Fatal error: Class '\ValueValidators\RangeValidator' not found in {...}/extensions/Validator/includes/ParamProcessor/ParamDefinitionFactory.php on line 181

Errors like this pop up on PHP 5.3.

This is because the behaviour for `new $class()` is different between 5.3 and 5.4.

For this:
  new \Foo\Bar();

In both 5.3 and 5.4 the autoloader will get the string 'Foo\Bar'.

But for this:
  $class = '\Foo\Bar';
  new $class();

PHP 5.4 will clean up the class name and the autoloader will get the string 'Foo\Bar'.
PHP 5.3 will leave it alone and the autoloader will get the string '\Foo\Bar'.

As a result when class names like '\ValueValidators\RangeValidator' and '\ValueValidators\NullValidator' are used, PHP 5.3 won't find any class.

ParamDefinitionFactory::newDefinition needs to strip leading \'s from $validator, do it's comparison against '\ValueValidators\NullValidator', and in the future callers should ideally avoid calling it with the leading \.
Comment 1 Jeroen De Dauw 2014-05-30 16:19:28 UTC
This is about using PHP 5.3 with an old version of MW? I seem to recall the MW autoloder being fixed quite some time ago, since this was a problem for Wikidata.

Also, old version of Validator? Please specify.
Comment 2 Daniel Friesen 2014-05-30 17:25:59 UTC
PHP is 5.3
The MW version and Validator are what is checked into the client tree.
MW is some version of 1.22 (alpha?).
And I'm not sure about Validator, it's a little old but the version is something like 1.0 beta so it's not too far behind the current.

I've confirmed that the ParamParser library itself is still doing raw comparisons against '\ValueValidators\NullValidator' which would be incorrect in any case.

I'll note that MediaWiki's autoloader is actually not used for this code, but after looking even further the spl autoloader function used has been updated to trim \\ so in theory this is fixed (though code should still avoid comparison against '\ValueValidators\NullValidator').
Comment 3 Daniel Friesen 2014-05-30 17:26:28 UTC
I'm not sure what to mark this as duplicate of.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links