Fix PEAR.php loading for Composer custom installers #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do not try to call require_once on PEAR.php if it has already been loaded by the autoloader.
Motivation
The
require_once
of PEAR.php can cause a fatal error if this file is not available on the PHP include path. When using an autoloader, such as with Composer, this file does not need to be loaded; we can avoid needlessly stopping execution simply by testing to see if the file is already available via the autoloader.Note that for a typical Composer application, the
require
line does not cause any problems, as Archive_Tar has aninclude
line in its composer.json that allows PHP to find it when requested. However, Composer custom installers cannot benefit from this, becauseinclude
and autoload files are not available in custom installers. Inside custom installers, Archive_Tar will fail if PEAR.php is not installed on the global PHP include path.For more information, see drupal-composer/drupal-project#111