Skip to content

Commit

Permalink
fix lib- platform requirements breaking system dependency resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Dec 15, 2015
1 parent 224bcd9 commit f78ea39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- Buildpack does not export PATH for multi-buildpack usage [David Zuelke]
- Composer limitation leads to lower than possible PHP versions getting resolved [David Zuelke]
- `lib-` platform package requirements may prevent dependency resolution [David Zuelke]

## v87 (2015-12-11)

Expand Down
6 changes: 4 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ $BUILD_DIR/.heroku/php-min/bin/php -r '
function mkreq($require) { return array_combine(array_map(function($v) { return "heroku-sys/$v"; }, array_keys($require)), $require); }
// check if require section demands a runtime
function hasreq($require) { return isset($require["php"]) || isset($require["hhvm"]); }
// filter platform reqs
$preqfilter = function($v) { return preg_match("#^(hhvm$|php(-64bit)?$|ext-)#", $v); };
// remove first arg (0)
array_shift($argv);
Expand All @@ -153,13 +155,13 @@ if(file_exists(getenv("COMPOSER_LOCK"))) {
$lock = json_decode(file_get_contents(getenv("COMPOSER_LOCK")), true);
// our main require will be what is in the lock "platform" key
$have_runtime_req |= hasreq($lock["platform"]);
$require = mkreq($lock["platform"]);
$require = mkreq(array_filter($lock["platform"], $preqfilter, ARRAY_FILTER_USE_KEY));
// for each package that has platform requirements we build a meta-package that we then depend on
// we cannot simply join all those requirements together with " " or "," because of the precedence of the "|" operator: requirements "5.*," and "^5.3.9|^7.0", which should lead to a PHP 5 install, would combine into "5.*,^5.3.9|^7.0" (there is no way to group requirements), and that would give PHP 7
$metapaks = [];
foreach($lock["packages"] as $package) {
// extract only platform reqs
$preq = array_intersect_key(isset($package["require"]) ? $package["require"] : [], array_flip(array_filter(array_keys(isset($package["require"]) ? $package["require"] : []), function($v) { return preg_match("#^(hhvm$|php(-64bit)?$|ext-)#", $v); })));
$preq = array_filter(isset($package["require"]) ? $package["require"] : [], $preqfilter, ARRAY_FILTER_USE_KEY);
if(!$preq) continue;
$have_runtime_req |= hasreq($preq);
$metapaks[] = [
Expand Down

0 comments on commit f78ea39

Please sign in to comment.