Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/updater.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-07 16:52:11 +0300
committerGitHub <noreply@github.com>2016-12-07 16:52:11 +0300
commitfa29d7bf080f7cb7314aae1caf4b8cb1bfcdcee1 (patch)
tree2a28e7610fb33432464d521ce2bc57d66863b131
parent49b1843146a76f8509f505be445d593eabf3f000 (diff)
parent01e1292c81789a738ab53846698f68d4cf951056 (diff)
Merge pull request #56 from nextcloud/disable-updater-when-flag-is-setv11.0RC2
Disable updater when flag is set
-rw-r--r--Changelog.md5
-rw-r--r--index.php6
-rw-r--r--lib/UpdateCommand.php20
-rw-r--r--lib/Updater.php6
-rw-r--r--tests/features/bootstrap/FeatureContext.php13
-rw-r--r--tests/features/cli.feature8
-rwxr-xr-xupdater.pharbin591418 -> 591718 bytes
7 files changed, 47 insertions, 11 deletions
diff --git a/Changelog.md b/Changelog.md
index b12907f..f12113f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,8 @@
+# 1.0.3 - 2016-12-07
+
+- general: send PHP version to get compatible updates
+- CLI: check if update should be run based on updater server response
+
# 1.0.2 - 2016-11-28
- CLI: verify that owner of config.php and updater process user are the same
diff --git a/index.php b/index.php
index fe6750e..017ca70 100644
--- a/index.php
+++ b/index.php
@@ -236,6 +236,12 @@ class Updater {
$updateText = 'No update available.';
}
+ if ($this->updateAvailable && isset($response['autoupdater']) && !($response['autoupdater'] === 1 || $response['autoupdater'] === '1')) {
+ $this->updateAvailable = false;
+
+ $updateText .= '<br />The updater is disabled for this update - please update manually.' . $response['autoupdater'];
+ }
+
$this->silentLog('[info] end of checkForUpdate() ' . $updateText);
return $updateText;
}
diff --git a/lib/UpdateCommand.php b/lib/UpdateCommand.php
index 572d1e9..8bc4f74 100644
--- a/lib/UpdateCommand.php
+++ b/lib/UpdateCommand.php
@@ -139,20 +139,22 @@ class UpdateCommand extends Command {
// needs to be called that early because otherwise updateAvailable() returns false
$updateString = $this->updater->checkForUpdate();
- if(!$this->updater->updateAvailable() && $stepNumber === 0) {
- $output->writeln('Everything is up to date.');
- return 0;
- }
-
$output->writeln('');
- $indexOfBreak = strpos($updateString, '<br');
- $output->writeln('<info>' . substr($updateString, 0, $indexOfBreak) . '</info>');
- // strip HTML
- $output->writeln(preg_replace('/<[^>]*>/', '', substr($updateString, $indexOfBreak)));
+ $lines = explode('<br />', $updateString);
+
+ foreach ($lines as $line) {
+ // strip HTML
+ $output->writeln('<info>' . preg_replace('/<[^>]*>/', '', $line) . '</info>');
+ }
$output->writeln('');
+ if(!$this->updater->updateAvailable() && $stepNumber === 0) {
+ $output->writeln('Nothing to do.');
+ return 0;
+ }
+
$questionText = 'Start update';
if ($stepNumber > 0) {
$questionText = 'Continue update';
diff --git a/lib/Updater.php b/lib/Updater.php
index 14b9d3f..5cfa34a 100644
--- a/lib/Updater.php
+++ b/lib/Updater.php
@@ -121,6 +121,12 @@ class Updater {
$updateText = 'No update available.';
}
+ if ($this->updateAvailable && isset($response['autoupdater']) && !($response['autoupdater'] === 1 || $response['autoupdater'] === '1')) {
+ $this->updateAvailable = false;
+
+ $updateText .= '<br />The updater is disabled for this update - please update manually.' . $response['autoupdater'];
+ }
+
$this->silentLog('[info] end of checkForUpdate() ' . $updateText);
return $updateText;
}
diff --git a/tests/features/bootstrap/FeatureContext.php b/tests/features/bootstrap/FeatureContext.php
index 7d69c1a..0f05432 100644
--- a/tests/features/bootstrap/FeatureContext.php
+++ b/tests/features/bootstrap/FeatureContext.php
@@ -21,6 +21,8 @@ class FeatureContext implements Context
protected $CLIOutput;
/** @var integer */
protected $CLIReturnCode;
+ /** @var string */
+ protected $autoupdater = '1';
public function __construct()
{
@@ -131,7 +133,14 @@ class FeatureContext implements Context
$content = '';
file_put_contents($this->updateServerDir . 'index.php', $content);
- }
+ }
+
+ /**
+ * @Given the autoupdater is disabled
+ */
+ public function theAutoupdaterIsDisabled() {
+ $this->autoupdater = '0';
+ }
/**
* @When the CLI updater is run successfully
@@ -178,7 +187,7 @@ class FeatureContext implements Context
<versionstring>Nextcloud ' . $version . '</versionstring>
<url>https://download.nextcloud.com/server/releases/nextcloud-' . $version . '.zip</url>
<web>https://docs.nextcloud.org/server/10/admin_manual/maintenance/manual_upgrade.html</web>
- <autoupdater>1</autoupdater>
+ <autoupdater>' . $this->autoupdater . '</autoupdater>
</nextcloud>
';
file_put_contents($this->updateServerDir . 'index.php', $content);
diff --git a/tests/features/cli.feature b/tests/features/cli.feature
index 491352f..0750a84 100644
--- a/tests/features/cli.feature
+++ b/tests/features/cli.feature
@@ -34,3 +34,11 @@ Feature: CLI updater
#And maintenance mode should be off
And upgrade is not required
+ Scenario: Update is available but autoupdate is disabled - 10.0.0 to 10.0.1
+ Given the current installed version is 10.0.0
+ And the autoupdater is disabled
+ And there is an update to version 10.0.1 available
+ When the CLI updater is run
+ Then the installed version should be 10.0.0
+ And maintenance mode should be off
+ And upgrade is not required
diff --git a/updater.phar b/updater.phar
index 7ee9268..fcd8ca0 100755
--- a/updater.phar
+++ b/updater.phar
Binary files differ