mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Add repair steps for legacy config files
Remove all ports from the trusted domains Conflicts: lib/private/repair.php lib/repair/repairconfig.php
This commit is contained in:
parent
d0a30b0e55
commit
260a084d27
2 changed files with 31 additions and 1 deletions
|
|
@ -93,7 +93,8 @@ class Repair extends BasicEmitter {
|
|||
$steps = array(
|
||||
new InnoDB(),
|
||||
new Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
|
||||
new SearchLuceneTables()
|
||||
new SearchLuceneTables(),
|
||||
new RepairConfig()
|
||||
);
|
||||
|
||||
//There is no need to delete all previews on every single update
|
||||
|
|
|
|||
|
|
@ -12,8 +12,16 @@ use OC\Hooks\BasicEmitter;
|
|||
use OC\RepairStep;
|
||||
use Sabre\DAV\Exception;
|
||||
|
||||
/**
|
||||
* Class RepairConfig
|
||||
*
|
||||
* @package OC\Repair
|
||||
*/
|
||||
class RepairConfig extends BasicEmitter implements RepairStep {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return 'Repair config';
|
||||
}
|
||||
|
|
@ -23,6 +31,7 @@ class RepairConfig extends BasicEmitter implements RepairStep {
|
|||
*/
|
||||
public function run() {
|
||||
$this->addSecret();
|
||||
$this->removePortsFromTrustedDomains();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,4 +43,24 @@ class RepairConfig extends BasicEmitter implements RepairStep {
|
|||
\OC::$server->getConfig()->setSystemValue('secret', $secret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove ports from existing trusted domains in config.php
|
||||
*/
|
||||
private function removePortsFromTrustedDomains() {
|
||||
$trustedDomains = \OC::$server->getConfig()->getSystemValue('trusted_domains', array());
|
||||
$newTrustedDomains = array();
|
||||
foreach($trustedDomains as $domain) {
|
||||
$pos = strrpos($domain, ':');
|
||||
if ($pos !== false) {
|
||||
$port = substr($domain, $pos + 1);
|
||||
if (is_numeric($port)) {
|
||||
$domain = substr($domain, 0, $pos);
|
||||
}
|
||||
}
|
||||
$newTrustedDomains[] = $domain;
|
||||
}
|
||||
\OC::$server->getConfig()->setSystemValue('trusted_domains', $newTrustedDomains);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue