Page MenuHomePhabricator

__DIR__ causes error
Closed, DeclinedPublic

Description

I checked out the AntiSpoof extension and afterwards, while running the upgrade script, I got an error similar to the following:

Warning: require(/home/path/w/__DIR__/AntiSpoofHooks.php): failed to open stream: No such file or directory in /home/path/w/includes/AutoLoader.php on line 1007
Fatal error: require(): Failed opening required '/home/path/w/__DIR__/AntiSpoofHooks.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/path/w/includes/AutoLoader.php on line 1007

I had to change the value from DIR to dirname( FILE ) . '/' to get the script to execute.

Afterwards, running batchAntiSpoof.php, I got similar errors, clearly showing DIR in the paths displayed.

In addition, with the SimpleAntiSpam, for an example, with $wgShowExceptionDetails set to true, I saw

Warning: include(__DIR__/SimpleAntiSpam.i18n.php) [function.include]: failed to open stream: No such file or directory in /home/path/w/includes/LocalisationCache.php on line 455

Warning: include(__DIR__/SimpleAntiSpam.i18n.php) [function.include]: failed to open stream: No such file or directory in /home/path/w/includes/LocalisationCache.php on line 455

Warning: include() [function.include]: Failed opening '__DIR__/SimpleAntiSpam.i18n.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/path/w/includes/LocalisationCache.php on line 455

These errors were resolved with the use of "dirname( FILE ) . '/'" instead of "DIR". Would it be better to use "dirname( FILE ) . '/'" in place of DIR in all cases then?

(Note: The wiki is on Linux OS and using an Apache server.)


Version: master
Severity: major

Details

Reference
bz41248

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:05 AM
bzimport added a project: AntiSpoof.
bzimport set Reference to bz41248.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to comment #1)

PHP version error.

Could you elaborate, e.g. which version you initially used and which version was needed?

From IRC:
<Hazard-SJ> MatmaRex: The server in question uses PHP 5.2.17

DIR was added in PHP 5.3.0.