|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-12-11 02:03 UTC] dante at lorenso dot com
Description: ------------ Given 2 different virtual hosts in Apache, if auto_prepend_file is used in both virtual hosts and the files contain the exact same data, the first virtual host loaded by Apache is used for all subsequent virtual hosts. Example ... <VirtualHost...> php_value auto_prepend_file bootstrap.php </VirtualHost> <VirtualHost...> php_value auto_prepend_file bootstrap.php </VirtualHost> Changing contents of just one of the bootstrap.php files to alter the contents will correct the problem and allow Apache to serve different virtual host DocumentRoot content. Expected result: ---------------- php_value auto_prepend_file bootstrap.php should be independent of file contents and should be defined separately for each virtual host without conflict. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 03:00:01 2025 UTC |
I added the following code to BOTH bootstrap.php files ... error_log(str_repeat('-', 80)); error_log('FILE: ' . __FILE__); error_log('DIR: ' . __DIR__); error_log('ROOT_DIR: ' . ROOT_DIR); $files = get_included_files(); edump($files); And here are the 2 outputs ... After loading the first virtual host URL(keydb): [Wed Dec 10 22:16:22.146732 2014] [:error] [pid 18058] [client 10.0.8.2:6687] FILE: /www/prod/keydb/public/bootstrap.php [Wed Dec 10 22:16:22.146840 2014] [:error] [pid 18058] [client 10.0.8.2:6687] DIR: /www/prod/keydb/public [Wed Dec 10 22:16:22.146926 2014] [:error] [pid 18058] [client 10.0.8.2:6687] ROOT_DIR: /www/prod/keydb [Wed Dec 10 22:16:22.147380 2014] [:error] [pid 18058] [client 10.0.8.2:6687] [01] Array\n(\n [0] => /www/prod/keydb/public/bootstrap.php\n)\n And after loading the second virtual host URL(acd): [Wed Dec 10 22:16:29.082052 2014] [:error] [pid 18056] [client 10.0.8.2:43767] FILE: /www/prod/keydb/public/bootstrap.php [Wed Dec 10 22:16:29.082153 2014] [:error] [pid 18056] [client 10.0.8.2:43767] DIR: /www/prod/keydb/public [Wed Dec 10 22:16:29.082236 2014] [:error] [pid 18056] [client 10.0.8.2:43767] ROOT_DIR: /www/prod/keydb [Wed Dec 10 22:16:29.082461 2014] [:error] [pid 18056] [client 10.0.8.2:43767] [01] Array\n(\n [0] => /www/dev/acd/public/bootstrap.php\n)\n NOTICE how loading the "acd" project ... in the get_included_files() array it lists the file name as /www/dev/acd/public/bootstrap.php? But, the value of __FILE__ lists a DIFFERENT file ... the one from the other virtual host: /www/prod/keydb/public/bootstrap.php. I agree now that this is not affecting the Apache 2 virtual hosts directly, but it IS a bug inside PHP somewhere. PHP is confused about which file it is actually parsing because get_included_files()[0] != __FILE__ For the auto_prepend_file declared in each virtual host. In my projects, it is not the same virtual host that is used, but it IS the same bootstrap.php file being used, so PHP sets all the define constants to values based on the bootstrap.php file: define('ROOT_DIR', realpath(__DIR__ . '/..')); And this triggers the SPL auto loader to use the wrong classes: // PSR-4: convert class name to file name $lib_file = ROOT_DIR . '/library/' . strtr(ltrim($class_name, '\\'), array('\\' => '/')) . '.php'; if (file_exists($lib_file)) { include $lib_file; return true; } Which effectively makes all the asset files and library classes load from the wrong site. -- DanteDefault Ubuntu 14.04 xcache settings are in use ... here is the default configuration: > php -i | grep -i xcache /etc/php5/cli/conf.d/20-xcache.ini, with XCache v3.1.0, Copyright (c) 2005-2013, by mOo with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo XCache XCache Version => 3.1.0 xcache.coredump_directory => no value => no value xcache.disable_on_crash => Off => Off xcache.experimental => Off => Off xcache.test => Off => Off XCache Cacher XCache Cacher Module => enabled xcache.admin.enable_auth => On => On xcache.allocator => bestfit => bestfit xcache.cacher => On => On xcache.count => 1 => 1 xcache.gc_interval => 0 => 0 xcache.mmap_path => /dev/zero => /dev/zero xcache.readonly_protection => Off => Off xcache.shm_scheme => mmap => mmap xcache.size => 60M => 60M xcache.slots => 8K => 8K xcache.stat => On => On xcache.ttl => 0 => 0 xcache.var_allocator => bestfit => bestfit xcache.var_count => 1 => 1 xcache.var_gc_interval => 300 => 300 xcache.var_maxttl => 0 => 0 xcache.var_namespace => cheese => cheese xcache.var_namespace_mode => 1 => 1 xcache.var_size => 4M => 4M xcache.var_slots => 8K => 8K xcache.var_ttl => 0 => 0 XCache Coverager XCache Coverager Module => enabled xcache.coveragedump_directory => no value => no value xcache.coverager => Off => Off xcache.coverager_autostart => On => On XCache Optimizer XCache Optimizer Module => enabled xcache.optimizer => Off => Off I will play more with some of these settings to see if I can re-enable XCache to work around the problem.