aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Updater.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Updater.php')
-rw-r--r--application/Updater.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/application/Updater.php b/application/Updater.php
index fd7e2073..0fb68c5a 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -378,6 +378,66 @@ class Updater
378 378
379 $this->conf->set('plugins.PIWIK_URL', 'http://'. $this->conf->get('plugins.PIWIK_URL')); 379 $this->conf->set('plugins.PIWIK_URL', 'http://'. $this->conf->get('plugins.PIWIK_URL'));
380 $this->conf->write($this->isLoggedIn); 380 $this->conf->write($this->isLoggedIn);
381
382 return true;
383 }
384
385 /**
386 * Use ATOM feed as default.
387 */
388 public function updateMethodAtomDefault()
389 {
390 if (!$this->conf->exists('feed.show_atom') || $this->conf->get('feed.show_atom') === true) {
391 return true;
392 }
393
394 $this->conf->set('feed.show_atom', true);
395 $this->conf->write($this->isLoggedIn);
396
397 return true;
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);
381 return true; 441 return true;
382 } 442 }
383} 443}