From 9c5b769cf0d32a54f2f97cd2c6e9c2caaacac371 Mon Sep 17 00:00:00 2001 From: Lucas Bickel Date: Mon, 17 Jul 2017 21:15:51 +0200 Subject: [PATCH] Fix update warning I fixed the manual installer to ensure that the VERSION file ends up in the right directory on install. I also took care of the pre-release parts of the naggingness. It shows no updates as long there is no stable release for the current version. As soon as one is available it uses the orange update icon to alert the user that an update would be in order since a stable version has been released. --- .../application/views/helpers/VersionNotify.php | 14 +++++++++----- install | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/views/helpers/VersionNotify.php b/airtime_mvc/application/views/helpers/VersionNotify.php index ca9aaf419..baf8826ad 100644 --- a/airtime_mvc/application/views/helpers/VersionNotify.php +++ b/airtime_mvc/application/views/helpers/VersionNotify.php @@ -32,18 +32,22 @@ class Airtime_View_Helper_VersionNotify extends Zend_View_Helper_Abstract { $currentParts = array(0, 0, 0, 0); } - $majorCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s', $currentParts[0] + 1)); + $isPreRelease = $isGitRelease || array_key_exists(4, $currentParts); + // we are always interested in a major when we pre-release, hence the isPreRelease part + $majorCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s-stable', $currentParts[0] + ($isPreRelease ? 0 : 1))); $minorCandidates = SemVer::satisfiedBy($latest, sprintf('~%1$s.%2$s', $currentParts[0], $currentParts[1] + 1)); - $patchCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s <%1$s.%3$s', $currentParts[0], $currentParts[1], $currentParts[2] + 1, $currentParts[1] + 1)); + $patchCandidates = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s <%1$s.%3$s', $currentParts[0], $currentParts[1], $currentParts[2] + 1)); $hasMajor = !empty($majorCandidates); $hasMinor = !empty($minorCandidates); $hasPatch = !empty($patchCandidates); - $isPreRelease = $isGitRelease || array_key_exists(4, $currentParts); $hasMultiMajor = count($majorCandidates) > 1; if ($isPreRelease) { - // orange "warning" if you are on unreleased code - $class = 'update2'; + $stableVersions = SemVer::satisfiedBy($latest, sprintf('>=%1$s.%2$s.%3$s-stable', $currentParts[0], $currentParts[1], $currentParts[2])); + // git releases are never interested in a stable version :P + $hasStable = !empty($stableVersions) && !$isGitRelease; + // no warning if no major release available, orange warning if you are on unreleased code + $class = $hasStable ? 'update2' : 'uptodate'; } else if ($hasPatch || $hasMultiMajor) { // current patch or more than 1 major behind $class = 'outdated'; diff --git a/install b/install index 5d34f1028..7e2cf2dd3 100755 --- a/install +++ b/install @@ -734,6 +734,7 @@ elif [ -n "$web_root" ]; then verbose "\n * Creating Apache web root directory..." cp -R ${AIRTIMEROOT}/airtime_mvc ${web_root} cp -R ${AIRTIMEROOT}/vendor ${web_root} + cp ${AIRTIMEROOT}/VERSION ${web_root} web_root=${web_root}/airtime_mvc/public/ else verbose "\n * Creating default Apache web root directory /usr/share/airtime/php..." @@ -741,6 +742,7 @@ else mkdir -p ${web_root} cp -R ${AIRTIMEROOT}/airtime_mvc ${web_root} cp -R ${AIRTIMEROOT}/vendor ${web_root} + cp ${AIRTIMEROOT}/VERSION ${web_root} web_root=${web_root}/airtime_mvc/public/ fi verbose "...Done"