Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgrade button with update from disk #8076

Merged
merged 1 commit into from Jul 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/Adapter/Module/Module.php
Expand Up @@ -154,6 +154,10 @@ public function __construct(array $attributes = array(), array $disk = array(),
$version = $this->attributes->get('version');
}

if (!$this->attributes->has('version_available')) {
$this->attributes->set('version_available', $this->disk->get('version'));
}

$img = $this->attributes->get('img');
if (empty($img)) {
$this->attributes->set('img', __PS_BASE_URI__.'img/questionmark.png');
Expand Down Expand Up @@ -332,10 +336,17 @@ public function fillLogo()

public function canBeUpgraded()
{
return
$this->database->get('installed') == 1
&& $this->attributes->get('version_available')
!== 0 && version_compare($this->database->get('version'), $this->attributes->get('version_available'), '<')
;
if ($this->database->get('installed') == 0) {
return false;
}

// Potential update from API
if ($this->attributes->get('version_available') !== 0
&& version_compare($this->database->get('version'), $this->attributes->get('version_available'), '<')) {
return true;
}

// Potential update from disk
return version_compare($this->database->get('version'), $this->disk->get('version'), '<');
}
}