Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions downloader/lib/Mage/Connect/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,10 @@ public function checkPhpVersion()
$min = $this->getDependencyPhpVersionMin();
$max = $this->getDependencyPhpVersionMax();

$minOk = $min? version_compare(PHP_VERSION, $min, ">=") : true;
$maxOk = $max? version_compare(PHP_VERSION, $max, "<=") : true;
$version = substr(PHP_VERSION,0,strpos(PHP_VERSION, "-"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution is not universal because the dash symbol is optional, PHP version format is "major.minor.release[extra]".
Suggested implementation:
substr(PHP_VERSION, 0, -strlen(PHP_EXTRA_VERSION))


$minOk = $min? version_compare($version, $min, ">=") : true;
$maxOk = $max? version_compare($version, $max, "<=") : true;

if(!$minOk || !$maxOk) {
$err = "requires PHP version ";
Expand Down
6 changes: 4 additions & 2 deletions lib/Mage/Connect/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,10 @@ public function checkPhpVersion()
$min = $this->getDependencyPhpVersionMin();
$max = $this->getDependencyPhpVersionMax();

$minOk = $min? version_compare(PHP_VERSION, $min, ">=") : true;
$maxOk = $max? version_compare(PHP_VERSION, $max, "<=") : true;
$version = substr(PHP_VERSION,0,strpos(PHP_VERSION, "-"));

$minOk = $min? version_compare($version, $min, ">=") : true;
$maxOk = $max? version_compare($version, $max, "<=") : true;

if(!$minOk || !$maxOk) {
$err = "requires PHP version ";
Expand Down