diff options
Diffstat (limited to 'application/ApplicationUtils.php')
-rw-r--r-- | application/ApplicationUtils.php | 18 |
1 files changed, 14 insertions, 4 deletions
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 @@ | |||
5 | class ApplicationUtils | 5 | class ApplicationUtils |
6 | { | 6 | { |
7 | private static $GIT_URL = 'https://raw.githubusercontent.com/shaarli/Shaarli'; | 7 | private static $GIT_URL = 'https://raw.githubusercontent.com/shaarli/Shaarli'; |
8 | private static $GIT_BRANCH = 'master'; | 8 | private static $GIT_BRANCHES = array('master', 'stable'); |
9 | private static $VERSION_FILE = 'shaarli_version.php'; | 9 | private static $VERSION_FILE = 'shaarli_version.php'; |
10 | private static $VERSION_START_TAG = '<?php /* '; | 10 | private static $VERSION_START_TAG = '<?php /* '; |
11 | private static $VERSION_END_TAG = ' */ ?>'; | 11 | private static $VERSION_END_TAG = ' */ ?>'; |
@@ -52,8 +52,12 @@ class ApplicationUtils | |||
52 | * | 52 | * |
53 | * @return mixed the new version code if available and greater, else 'false' | 53 | * @return mixed the new version code if available and greater, else 'false' |
54 | */ | 54 | */ |
55 | public static function checkUpdate( | 55 | public static function checkUpdate($currentVersion, |
56 | $currentVersion, $updateFile, $checkInterval, $enableCheck, $isLoggedIn) | 56 | $updateFile, |
57 | $checkInterval, | ||
58 | $enableCheck, | ||
59 | $isLoggedIn, | ||
60 | $branch='stable') | ||
57 | { | 61 | { |
58 | if (! $isLoggedIn) { | 62 | if (! $isLoggedIn) { |
59 | // Do not check versions for visitors | 63 | // Do not check versions for visitors |
@@ -75,10 +79,16 @@ class ApplicationUtils | |||
75 | return false; | 79 | return false; |
76 | } | 80 | } |
77 | 81 | ||
82 | if (! in_array($branch, self::$GIT_BRANCHES)) { | ||
83 | throw new Exception( | ||
84 | 'Invalid branch selected for updates: "' . $branch . '"' | ||
85 | ); | ||
86 | } | ||
87 | |||
78 | // Late Static Binding allows overriding within tests | 88 | // Late Static Binding allows overriding within tests |
79 | // See http://php.net/manual/en/language.oop5.late-static-bindings.php | 89 | // See http://php.net/manual/en/language.oop5.late-static-bindings.php |
80 | $latestVersion = static::getLatestGitVersionCode( | 90 | $latestVersion = static::getLatestGitVersionCode( |
81 | self::$GIT_URL . '/' . self::$GIT_BRANCH . '/' . self::$VERSION_FILE | 91 | self::$GIT_URL . '/' . $branch . '/' . self::$VERSION_FILE |
82 | ); | 92 | ); |
83 | 93 | ||
84 | if (! $latestVersion) { | 94 | if (! $latestVersion) { |