Skip to content

Commit

Permalink
Disable full platform-check for extensions by default, now set to php…
Browse files Browse the repository at this point in the history
…-only, refs composer#9412
  • Loading branch information
Seldaek committed Nov 4, 2020
1 parent fc0d724 commit 6c31744
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions res/composer-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@
"description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
},
"platform-check": {
"type": "boolean",
"description": "Defaults to true. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
"type": ["boolean", "string"],
"description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/Composer/Autoload/AutoloadGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static function autoload(\$class)
$checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
$platformCheckContent = null;
if ($checkPlatform) {
$platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array());
$platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check'));
if (null === $platformCheckContent) {
$checkPlatform = false;
}
Expand Down Expand Up @@ -609,7 +609,7 @@ protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $
return $baseDir . (($path !== false) ? var_export($path, true) : "");
}

protected function getPlatformCheck($packageMap, array $ignorePlatformReqs)
protected function getPlatformCheck($packageMap, array $ignorePlatformReqs, $checkPlatform)
{
$lowestPhpVersion = Bound::zero();
$requiredExtensions = array();
Expand Down Expand Up @@ -637,7 +637,7 @@ protected function getPlatformCheck($packageMap, array $ignorePlatformReqs)
}
}

if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
// skip extension checks if they have a valid provider/replacer
if (isset($extensionProviders[$match[1]])) {
foreach ($extensionProviders[$match[1]] as $provided) {
Expand Down
13 changes: 12 additions & 1 deletion src/Composer/Command/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,18 @@ function ($val) {
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
'lock' => array($booleanValidator, $booleanNormalizer),
'platform-check' => array($booleanValidator, $booleanNormalizer),
'platform-check' => array(
function ($val) {
return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
},
function ($val) {
if ('php-only' === $val) {
return 'php-only';
}

return $val !== 'false' && (bool) $val;
},
),
);
$multiConfigValues = array(
'github-protocols' => array(
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Config
'htaccess-protect' => true,
'use-github-api' => true,
'lock' => true,
'platform-check' => true,
'platform-check' => 'php-only',
// valid keys without defaults (auth config stuff):
// bitbucket-oauth
// github-oauth
Expand Down

0 comments on commit 6c31744

Please sign in to comment.