diff --git a/Changelog.md b/Changelog.md
index b12907f3..f12113f0 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 fe6750e4..017ca708 100644
--- a/index.php
+++ b/index.php
@@ -236,6 +236,12 @@ public function checkForUpdate() {
$updateText = 'No update available.';
}
+ if ($this->updateAvailable && isset($response['autoupdater']) && !($response['autoupdater'] === 1 || $response['autoupdater'] === '1')) {
+ $this->updateAvailable = false;
+
+ $updateText .= '
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 572d1e97..8bc4f749 100644
--- a/lib/UpdateCommand.php
+++ b/lib/UpdateCommand.php
@@ -139,20 +139,22 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// 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, '
writeln('' . substr($updateString, 0, $indexOfBreak) . '');
- // strip HTML
- $output->writeln(preg_replace('/<[^>]*>/', '', substr($updateString, $indexOfBreak)));
+ $lines = explode('
', $updateString);
+
+ foreach ($lines as $line) {
+ // strip HTML
+ $output->writeln('' . preg_replace('/<[^>]*>/', '', $line) . '');
+ }
$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 14b9d3f6..5cfa34a4 100644
--- a/lib/Updater.php
+++ b/lib/Updater.php
@@ -121,6 +121,12 @@ public function checkForUpdate() {
$updateText = 'No update available.';
}
+ if ($this->updateAvailable && isset($response['autoupdater']) && !($response['autoupdater'] === 1 || $response['autoupdater'] === '1')) {
+ $this->updateAvailable = false;
+
+ $updateText .= '
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 7d69c1ad..0f05432a 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 @@ public function thereIsNoUpdateAvailable()
$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 @@ public function thereIsAnUpdateToVersionAvailable($version)
Nextcloud ' . $version . '
https://download.nextcloud.com/server/releases/nextcloud-' . $version . '.zip
https://docs.nextcloud.org/server/10/admin_manual/maintenance/manual_upgrade.html
- 1
+ ' . $this->autoupdater . '
';
file_put_contents($this->updateServerDir . 'index.php', $content);
diff --git a/tests/features/cli.feature b/tests/features/cli.feature
index 491352f9..0750a84d 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