|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-25 22:15 UTC] shire@php.net
[2011-01-03 12:51 UTC] whfwoefh at wasteland dot rfc822 dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
Description: ------------ A file that require()s a config file located in dirname(__FILE__) and outputs a constant is hard-linked in multiple sites hosted on the same server. The constant for the site from which the file was requested the first time gets cached and is returned in subsequent requests regardless of the site. It works fine if the file is *unhardlinked*. It also works if dirname(__FILE__) is removed or just replaced with './'. Reproduce code: --------------- foo.example.com and bar.example.com have the same copies of test.php and config.php. # sha1sum /www/*/{test,config}.php a0af22d58a7a7a5fd11547cd304cc08968c13d5c /www/bar.example.com/test.php a0af22d58a7a7a5fd11547cd304cc08968c13d5c /www/foo.example.com/test.php 4494ec973dfed496e4b28f1ae6e4e2224d10a66c /www/bar.example.com/config.php 4494ec973dfed496e4b28f1ae6e4e2224d10a66c /www/foo.example.com/config.php but test.php is hard-linked # ls -il /www/*/{test,config}.php | awk '{print $1, $10}' | sort -rn 5640819 /www/foo.example.com/test.php 5640819 /www/bar.example.com/test.php 4792040 /www/bar.example.com/config.php 4792039 /www/foo.example.com/config.php # cat /www/foo.example.com/test.php <?php require(dirname(__FILE__) . '/config.php'); echo ABSPATH; ?> # cat /www/foo.example.com/config.php <?php define('ABSPATH', dirname(__FILE__).'/'); ?> Expected result: ---------------- "echo ABSPATH;" should return the ABSPATH for foo if foo.example.com is requested and the ABSPATH for bar if bar.example.com is requested. Actual result: -------------- # service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] # curl -H 'Host: foo.example.com' http://127.0.0.1/test.php /www/foo.example.com/ # curl -H 'Host: bar.example.com' http://127.0.0.1/test.php /www/foo.example.com/ # service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] # curl -H 'Host: bar.example.com' http://127.0.0.1/test.php /www/bar.example.com/ # curl -H 'Host: foo.example.com' http://127.0.0.1/test.php /www/bar.example.com/