Skip to content

Commit

Permalink
Align updater class with index.php
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
  • Loading branch information
PVince81 authored and backportbot[bot] committed Mar 23, 2021
1 parent b655d27 commit 3dc32a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function __construct($baseDir) {
require_once $configFileName;
$this->configValues = $CONFIG;

if (php_sapi_name() !== 'cli' && $this->configValues['upgrade.disable-web'] ?? false) {
if (php_sapi_name() !== 'cli' && ($this->configValues['upgrade.disable-web'] ?? false)) {
// updater disabled
$this->disabled = true;
return;
Expand Down
17 changes: 17 additions & 0 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Updater {
private $updateAvailable = false;
/** @var string */
private $requestID = null;
/** @var bool */
private $disabled = false;

/**
* Updater constructor
Expand All @@ -58,6 +60,12 @@ public function __construct($baseDir) {
require_once $configFileName;
$this->configValues = $CONFIG;

if (php_sapi_name() !== 'cli' && ($this->configValues['upgrade.disable-web'] ?? false)) {
// updater disabled
$this->disabled = true;
return;
}

$dataDir = $this->getDataDirectoryLocation();
if(empty($dataDir) || !is_string($dataDir)) {
throw new \Exception('Could not read data directory from config.php.');
Expand Down Expand Up @@ -93,6 +101,15 @@ public function __construct($baseDir) {
$this->buildTime = $buildTime;
}

/**
* Returns whether the web updater is disabled
*
* @return bool
*/
public function isDisabled() {
return $this->disabled;
}

/**
* Returns current version or "unknown" if this could not be determined.
*
Expand Down

0 comments on commit 3dc32a9

Please sign in to comment.