aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-11-30 02:03:32 +0100
committerVirtualTam <virtualtam@flibidi.net>2015-11-30 02:03:32 +0100
commit05f21ea82130dca0bf49a16630105d1c5649e6c6 (patch)
tree0604f1af0688325fc8871161a650a7a4ee22fe34 /application
parent1b740e3de39172975d0e755d9a089d2e9a44279d (diff)
parent4407b45fd3b09257ea79edba8d4f50db350f8fa9 (diff)
downloadShaarli-05f21ea82130dca0bf49a16630105d1c5649e6c6.tar.gz
Shaarli-05f21ea82130dca0bf49a16630105d1c5649e6c6.tar.zst
Shaarli-05f21ea82130dca0bf49a16630105d1c5649e6c6.zip
Merge pull request #394 from virtualtam/app-utils/check-update/stable-branch
application: default to the "stable" branch for update checks
Diffstat (limited to 'application')
-rw-r--r--application/ApplicationUtils.php18
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 @@
5class ApplicationUtils 5class 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) {