Skip to content

Commit dec1fec

Browse files
committed
improve overwrite cli url setup check
Signed-off-by: szaimen <szaimen@e.mail.de>
1 parent 8f6a3f4 commit dec1fec

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,25 @@ protected function hasWorkingFileLocking(): bool {
609609
}
610610

611611
protected function getSuggestedOverwriteCliURL(): string {
612-
$suggestedOverwriteCliUrl = '';
613-
if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
614-
$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
612+
$currentOverwriteCliUrl = $this->config->getSystemValue('overwrite.cli.url', '');
613+
$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
614+
615+
// Set if not set yet
616+
if ($currentOverwriteCliUrl === '') {
615617
if (!$this->config->getSystemValue('config_is_read_only', false)) {
616618
// Set the overwrite URL when it was not set yet.
617619
$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
618-
$suggestedOverwriteCliUrl = '';
620+
$currentOverwriteCliUrl = $suggestedOverwriteCliUrl;
619621
}
620622
}
623+
624+
// Check correctness by comparing with suggested URL
625+
// This might lead to false positives though but that is fine since you should access your Nextcloud via the here defined URL either way
626+
// In case of a false positive, simply ignore the suggestion
627+
if ($suggestedOverwriteCliUrl === rtrim($currentOverwriteCliUrl, "/")) {
628+
$suggestedOverwriteCliUrl = '';
629+
}
630+
621631
return $suggestedOverwriteCliUrl;
622632
}
623633

core/js/setupchecks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
}
226226
if (data.suggestedOverwriteCliURL !== '') {
227227
messages.push({
228-
msg: t('core', 'If your installation is not installed at the root of the domain and uses system cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (suggestion: "{suggestedOverwriteCliURL}")', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}),
228+
msg: t('core', 'Please make sure to set the "overwrite.cli.url" option in your config.php file to the URL that your users mainly use to access this Nextcloud. Suggestion: "{suggestedOverwriteCliURL}". Otherwise there might be problems with the URL generation via cron. (It is possible though that the suggested URL is wrong and you have already set it to the correct value. In that case, just ignore this suggestion.)', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}),
229229
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
230230
});
231231
}

0 commit comments

Comments
 (0)