Skip to content

Commit b0a496c

Browse files
authored
Merge pull request #57 from MightyMCoder/develop
bugfix update check
2 parents 3edf080 + 8cd529f commit b0a496c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

preferences/preferences_check_for_update.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ function getLatestBetaReleaseVersion($owner, $repo) {
106106
$data = json_decode($response, true);
107107
foreach ($data as $release) {
108108
if ($release['prerelease']) {
109-
return ['version' => ltrim($data['tag_name'], 'v'), 'release' => $release['name'], 'url' => $data['html_url']];
109+
return ['version' => ltrim($release['tag_name'], 'v'), 'url' => $release['html_url']];
110110
}
111111
}
112112

113-
return ['version' => 'n/a', 'release' => '', 'url' => ''];
113+
return ['version' => 'n/a', 'url' => ''];
114114
}
115115

116116
/**
@@ -125,7 +125,7 @@ function getLatestBetaReleaseVersion($owner, $repo) {
125125
* @param string $betaFlag The current beta version of the plugin.
126126
* @return int An integer value indicating the update state.
127127
*/
128-
function checkVersion(string $currentVersion, string $checkStableVersion, string $checkBetaVersion, string $betaRelease, string $betaFlag): int
128+
function checkVersion(string $currentVersion, string $checkStableVersion, string $currentBetaVersion, string $checkBetaVersion): int
129129
{
130130
// Update state (0 = No update, 1 = New stable version, 2 = New beta version, 3 = New stable + beta version)
131131
$update = 0;
@@ -137,7 +137,7 @@ function checkVersion(string $currentVersion, string $checkStableVersion, string
137137

138138
// Check for beta version now
139139
$status = version_compare($checkBetaVersion, $currentVersion);
140-
if ($status === 1 || ($status === 0 && version_compare($betaRelease, $betaFlag, '>'))) {
140+
if ($status === 1 || ($status === 0 && version_compare($checkBetaVersion, $currentBetaVersion, '>'))) {
141141
if ($update === 1) {
142142
$update = 3;
143143
} else {
@@ -159,7 +159,6 @@ function checkVersion(string $currentVersion, string $checkStableVersion, string
159159
$stableURL = $stableInfo['url'];
160160

161161
$betaVersion = $betaInfo['version'];
162-
$betaRelease = $betaInfo['release'];
163162
$betaURL = $betaInfo['url'];
164163

165164
// No stable version available (actually impossible)
@@ -170,11 +169,10 @@ function checkVersion(string $currentVersion, string $checkStableVersion, string
170169
// No beta version available
171170
if ($betaVersion === '') {
172171
$betaVersion = 'n/a';
173-
$betaRelease = '';
174172
}
175173

176174
// check for update
177-
$versionUpdate = checkVersion($PIMVersion, $stableVersion, $betaVersion, $betaRelease, $PIMBetaVersion);
175+
$versionUpdate = checkVersion($PIMVersion, $stableVersion, $PIMBetaVersion, $betaVersion);
178176

179177

180178
// Only continues in display mode, otherwise the current update state can be
@@ -212,7 +210,7 @@ function checkVersion(string $currentVersion, string $checkStableVersion, string
212210
if ($versionUpdate !== 99 && $betaVersion !== 'n/a') {
213211
echo '
214212
<a class="btn" href="'.$betaURL.'" title="' . $gL10n->get('PLG_INVENTORY_MANAGER_DOWNLOAD_PAGE') . '" target="_blank">'.
215-
'<i class="fas fa-link"></i>' . $betaVersion . ' Beta ' . $betaRelease . '
213+
'<i class="fas fa-link"></i>' . $betaVersion . ' Beta
216214
</a>';
217215
} else {
218216
echo $betaVersion;

0 commit comments

Comments
 (0)