X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FApplicationUtils.php;h=274331e16f6fe21ac444f330b25c69a0d09e1fe5;hb=453f4653c325dc23193e16432170bf634c42e8a2;hp=c7414b776e56fdef23e5aef76f358566e7d50e21;hpb=1b740e3de39172975d0e755d9a089d2e9a44279d;p=github%2Fshaarli%2FShaarli.git diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index c7414b77..274331e1 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 = ''; @@ -50,10 +50,16 @@ class ApplicationUtils * @param bool $enableCheck whether to check for new versions * @param bool $isLoggedIn whether the user is logged in * + * @throws Exception an invalid branch has been set for update checks + * * @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 +81,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) {