summaryrefslogtreecommitdiffstats
path: root/lib/private/Settings
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-17 13:34:23 +0100
committerJoas Schilling <coding@schilljs.com>2017-03-17 13:40:58 +0100
commit75b81c3e01f3a5dc97e78c8e82fd5f94a071daba (patch)
treeca1e4806fe017748f8d4dcf209adae714c5fa8e4 /lib/private/Settings
parenta5c8016c8b7c50f73b7a16b6bd2284ed06f35d8e (diff)
downloadnextcloud-server-75b81c3e01f3a5dc97e78c8e82fd5f94a071daba.tar.gz
nextcloud-server-75b81c3e01f3a5dc97e78c8e82fd5f94a071daba.zip
Always suggest the overwrite.cli.url
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Settings')
-rw-r--r--lib/private/Settings/Admin/Server.php21
-rw-r--r--lib/private/Settings/Manager.php8
2 files changed, 22 insertions, 7 deletions
diff --git a/lib/private/Settings/Admin/Server.php b/lib/private/Settings/Admin/Server.php
index 8b1477a0257..5443336669f 100644
--- a/lib/private/Settings/Admin/Server.php
+++ b/lib/private/Settings/Admin/Server.php
@@ -32,12 +32,15 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
+use OCP\IRequest;
use OCP\Lock\ILockingProvider;
use OCP\Settings\ISettings;
class Server implements ISettings {
/** @var IDBConnection|Connection */
private $db;
+ /** @var IRequest */
+ private $request;
/** @var IConfig */
private $config;
/** @var ILockingProvider */
@@ -47,15 +50,18 @@ class Server implements ISettings {
/**
* @param IDBConnection $db
+ * @param IRequest $request
* @param IConfig $config
* @param ILockingProvider $lockingProvider
* @param IL10N $l
*/
public function __construct(IDBConnection $db,
+ IRequest $request,
IConfig $config,
ILockingProvider $lockingProvider,
IL10N $l) {
$this->db = $db;
+ $this->request = $request;
$this->config = $config;
$this->lockingProvider = $lockingProvider;
$this->l = $l;
@@ -99,12 +105,15 @@ class Server implements ISettings {
$fileLockingType = 'cache';
}
- // If the current web root is non-empty but the web root from the config is,
- // and system cron is used, the URL generator fails to build valid URLs.
- $shouldSuggestOverwriteCliUrl = $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron'
- && \OC::$WEBROOT && \OC::$WEBROOT !== '/'
- && !$this->config->getSystemValue('overwrite.cli.url', '');
- $suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : '';
+ $suggestedOverwriteCliUrl = '';
+ if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
+ $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
+ if (!$this->config->getSystemValue('config_is_read_only', false)) {
+ // Set the overwrite URL when it was not set yet.
+ $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
+ $suggestedOverwriteCliUrl = '';
+ }
+ }
$parameters = [
// Diagnosis
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index 7a339b94199..94df00551d4 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -29,6 +29,7 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
+use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
@@ -56,6 +57,8 @@ class Manager implements IManager {
private $userManager;
/** @var ILockingProvider */
private $lockingProvider;
+ /** @var IRequest */
+ private $request;
/** @var IURLGenerator */
private $url;
@@ -67,6 +70,7 @@ class Manager implements IManager {
* @param EncryptionManager $encryptionManager
* @param IUserManager $userManager
* @param ILockingProvider $lockingProvider
+ * @param IRequest $request
* @param Mapper $mapper
* @param IURLGenerator $url
*/
@@ -78,6 +82,7 @@ class Manager implements IManager {
EncryptionManager $encryptionManager,
IUserManager $userManager,
ILockingProvider $lockingProvider,
+ IRequest $request,
Mapper $mapper,
IURLGenerator $url
) {
@@ -89,6 +94,7 @@ class Manager implements IManager {
$this->encryptionManager = $encryptionManager;
$this->userManager = $userManager;
$this->lockingProvider = $lockingProvider;
+ $this->request = $request;
$this->url = $url;
}
@@ -299,7 +305,7 @@ class Manager implements IManager {
try {
if ($section === 'server') {
/** @var ISettings $form */
- $form = new Admin\Server($this->dbc, $this->config, $this->lockingProvider, $this->l);
+ $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l);
$forms[$form->getPriority()] = [$form];
$form = new Admin\ServerDevNotice();
$forms[$form->getPriority()] = [$form];