From 4407b45fd3b09257ea79edba8d4f50db350f8fa9 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Fri, 27 Nov 2015 00:10:43 +0100 Subject: application: default to the "stable" branch for update checks Relates to #372 Relates to #390 Signed-off-by: VirtualTam --- application/ApplicationUtils.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'application') diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index c7414b77..6d878110 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php @@ -5,7 +5,7 @@ class ApplicationUtils { private static $GIT_URL = 'https://raw.githubusercontent.com/shaarli/Shaarli'; - private static $GIT_BRANCH = 'master'; + private static $GIT_BRANCHES = array('master', 'stable'); private static $VERSION_FILE = 'shaarli_version.php'; private static $VERSION_START_TAG = ''; @@ -52,8 +52,12 @@ class ApplicationUtils * * @return mixed the new version code if available and greater, else 'false' */ - public static function checkUpdate( - $currentVersion, $updateFile, $checkInterval, $enableCheck, $isLoggedIn) + public static function checkUpdate($currentVersion, + $updateFile, + $checkInterval, + $enableCheck, + $isLoggedIn, + $branch='stable') { if (! $isLoggedIn) { // Do not check versions for visitors @@ -75,10 +79,16 @@ class ApplicationUtils return false; } + if (! in_array($branch, self::$GIT_BRANCHES)) { + throw new Exception( + 'Invalid branch selected for updates: "' . $branch . '"' + ); + } + // Late Static Binding allows overriding within tests // See http://php.net/manual/en/language.oop5.late-static-bindings.php $latestVersion = static::getLatestGitVersionCode( - self::$GIT_URL . '/' . self::$GIT_BRANCH . '/' . self::$VERSION_FILE + self::$GIT_URL . '/' . $branch . '/' . self::$VERSION_FILE ); if (! $latestVersion) { -- cgit v1.2.3