Prevent some unnecessary lstat system calls, generated by include or require directives.
authorNick Jenkins <nickj@users.mediawiki.org>
Fri, 9 Feb 2007 05:36:56 +0000 (05:36 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Fri, 9 Feb 2007 05:36:56 +0000 (05:36 +0000)
commitbaaee13afceb192e1666f0613a6d70486c91b14f
tree2175cd2bd8894fbbe6752bc909ab3a95dc01d10a
parentb909447ed2e9e7643f94f91fb1b1582f5eda8d19
Prevent some unnecessary lstat system calls, generated by include or require directives.

This can be done either by:
* Using explicit full paths, using the $IP global for the installation directory full path, and then working down the tree from there.
* Using explicit full paths, using the "dirname(__FILE__)" directive to get a full directory path for the includer file.
* Occasionally removing the line altogether, and then for some files the inclusion is handled by the autoloader.

For example, if the "extensions/wikihiero/wh_main.php" file does an include or require on "wh_list.php", then PHP does the following:
* tries to open "wiki/wh_list.php", and fails.
* tries to open "wiki/includes/wh_list.php", and fails.
* tries to open "wiki/languages/wh_list.php", and fails.
* tries to open "wiki/extensions/wikihiero/wh_list.php", and succeeds.

So in this example, the first 3 calls can be prevented if PHP is told where the file is.

Testing Method: On a Linux box, run these commands to attach strace to all the apache2 processes, and log their system calls to a temporary file, then generate some activity, and then stop the strace:
-----------------------------------
rm /tmp/strace-log.txt
strace -tt -o /tmp/strace-log.txt -p `pidof apache2 | sed 's/ / -p /g'` &
php maintenance/fuzz-tester.php --keep-passed-tests --include-binary --max-runtime=3 > /tmp/strace-tests.txt
killall -9 strace
grep "No such file or directory"  /tmp/strace-log.txt | sort -u
-----------------------------------

Any failed file stats will be marked with: "-1 ENOENT (No such file or directory)".

Also:
* Strict Standards: Undefined offset:  230 in includes/normal/UtfNormal.php on line 637
* Strict Standards: iconv() [<a href='function.iconv'>function.iconv</a>]: Detected an illegal character in input string in languages/Language.php on line 776
  [Note: Partial only - despite adding "//IGNORE", it still seems to be possible with some
         messed- up binary input to cause PHP 5.1.2's iconv() function to squeal like a stuck pig].
* Update one $fname variable (method belongs to HistoryBlobStub class).
19 files changed:
includes/AutoLoader.php
includes/GlobalFunctions.php
includes/HistoryBlob.php
includes/SpecialPage.php
includes/SpecialPrefixindex.php
includes/SpecialRecentchanges.php
includes/SpecialUserrights.php
includes/SpecialWatchlist.php
includes/Title.php
includes/normal/UtfNormal.php
languages/Language.php
skins/Chick.deps.php
skins/Chick.php
skins/MySkin.deps.php
skins/MySkin.php
skins/Simple.deps.php
skins/Simple.php
thumb.php
trackback.php