Skip to content

Commit

Permalink
Prevent APC causing random fatal errors [fixes composer#264]
Browse files Browse the repository at this point in the history
Update the phar stub to prevent APC attempting to run the composer classes through
the opcode cache on supported APC versions to avoid the random fatal "duplicate
class" errors at runtime as reported in composer#264.

Prior to APC version 3.0.12 this was a PHP_INI_SYSTEM directive, so output a
warning instead.
  • Loading branch information
acoulton committed Dec 3, 2014
1 parent 2b7b605 commit 2762fdd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Composer/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ private function getStub()
* the license that is located at the bottom of this file.
*/
// Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
if (extension_loaded('apc') && ini_get('apc.enable_cli') && ini_get('apc.cache_by_default') {
if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
ini_set('apc.cache_by_default', 0);
} else {
print "Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.".PHP_EOL;
print "Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.".PHP_EOL;
}
}
Phar::mapPhar('composer.phar');

EOF;
Expand Down

0 comments on commit 2762fdd

Please sign in to comment.