diff options
Diffstat (limited to 'application/Updater.php')
-rw-r--r-- | application/Updater.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/application/Updater.php b/application/Updater.php index efbfc832..0fb68c5a 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -396,6 +396,50 @@ class Updater | |||
396 | 396 | ||
397 | return true; | 397 | return true; |
398 | } | 398 | } |
399 | |||
400 | /** | ||
401 | * Update updates.check_updates_branch setting. | ||
402 | * | ||
403 | * If the current major version digit matches the latest branch | ||
404 | * major version digit, we set the branch to `latest`, | ||
405 | * otherwise we'll check updates on the `stable` branch. | ||
406 | * | ||
407 | * No update required for the dev version. | ||
408 | * | ||
409 | * Note: due to hardcoded URL and lack of dependency injection, this is not unit testable. | ||
410 | * | ||
411 | * FIXME! This needs to be removed when we switch to first digit major version | ||
412 | * instead of the second one since the versionning process will change. | ||
413 | */ | ||
414 | public function updateMethodCheckUpdateRemoteBranch() | ||
415 | { | ||
416 | if (shaarli_version === 'dev' || $this->conf->get('updates.check_updates_branch') === 'latest') { | ||
417 | return true; | ||
418 | } | ||
419 | |||
420 | // Get latest branch major version digit | ||
421 | $latestVersion = ApplicationUtils::getLatestGitVersionCode( | ||
422 | 'https://raw.githubusercontent.com/shaarli/Shaarli/latest/shaarli_version.php', | ||
423 | 5 | ||
424 | ); | ||
425 | if (preg_match('/(\d+)\.\d+$/', $latestVersion, $matches) === false) { | ||
426 | return false; | ||
427 | } | ||
428 | $latestMajor = $matches[1]; | ||
429 | |||
430 | // Get current major version digit | ||
431 | preg_match('/(\d+)\.\d+$/', shaarli_version, $matches); | ||
432 | $currentMajor = $matches[1]; | ||
433 | |||
434 | if ($currentMajor === $latestMajor) { | ||
435 | $branch = 'latest'; | ||
436 | } else { | ||
437 | $branch = 'stable'; | ||
438 | } | ||
439 | $this->conf->set('updates.check_updates_branch', $branch); | ||
440 | $this->conf->write($this->isLoggedIn); | ||
441 | return true; | ||
442 | } | ||
399 | } | 443 | } |
400 | 444 | ||
401 | /** | 445 | /** |