r62757 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62756‎ | r62757 | r62758 >
Date:01:44, 21 February 2010
Author:simetrical
Status:resolved (Comments)
Tags:
Comment:
Improve README slightly

Suggest require_once instead of require, note default ffmpeg location.
Modified paths:
  • /trunk/extensions/OggHandler/README (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/README
@@ -4,7 +4,7 @@
55
66 To install this extension, add the following to the end of your LocalSettings.php:
77
8 - require( "$IP/extensions/OggHandler/OggHandler.php" );
 8+ require_once( "$IP/extensions/OggHandler/OggHandler.php" );
99
1010 FFmpeg
1111 ------
@@ -33,7 +33,8 @@
3434
3535 $wgFFmpegLocation = '/path/to/ffmpeg';
3636
37 -after the require line in LocalSettings.php.
 37+after the require line in LocalSettings.php. (The default is
 38+'/usr/bin/ffmpeg'.)
3839
3940 Cortado
4041 -------

Follow-up revisions

RevisionCommit summaryAuthorDate
r62881Suggest require() instead of require_once()...simetrical17:13, 23 February 2010

Comments

#Comment by Tim Starling (talk | contribs)   10:41, 22 February 2010

Why would you use require_once() instead of require()? require() is faster, which is why my LocalSettings.php doesn't contain any instances of require_once().

#Comment by Simetrical (talk | contribs)   15:11, 22 February 2010

Because I've had cases (not with MediaWiki, as it happens) where a careless error meant that a file was being included multiple times in a small percentage of cases, which caused a fatal error when I added a function definition to the file. How significant is the performance difference in practice, with the number of inclusions we do? If we should really recommend require() instead of require_once(), then we should do it consistently – pretty much all extension documentation I've seen currently recommends require_once().

#Comment by Tim Starling (talk | contribs)   02:16, 23 February 2010

The difference is that with APC enabled and the file cached, require_once() opens the file and require() does not. So the amount of time difference depends on how fast your filesystem is. It's very noticeable if you're running over NFS.

When Rasmus was challenged about the problem, in typical fashion, he declared that apps should just know whether they have included their files or not, and that require() should be good enough for any well-designed app. At the time, we were migrating from explicit require_once() calls to the new AutoLoader, which implicitly knows when a file has been included due to class existence, thus we were able to remove almost all require_once() calls from MediaWiki, and speed it up for NFS installations substantially.

Eventually APC acquired the configuration hack "apc.include_once_override", but there are reports that it is buggy.

Yes, I would be happy if the documentation consistently recommended require() over require_once().

#Comment by Simetrical (talk | contribs)   17:14, 23 February 2010

Reverted that part in r62881. There's a lot more to do, though:

0 12:12:22 /var/www/git-trunk$ git grep 'require_once(' | wc -l
1576
0 12:12:30 /var/www/git-trunk$ git grep 'require(' | wc -l
163

Of course, a wholesale change to require() would probably be a bad idea, since it would introduce bugs.

#Comment by Siebrand (talk | contribs)   18:28, 23 February 2010

Well, bring it on. If they are there, getting to know them and fixing them quickly is one way to get rid of them...

Status & tagging log