X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FBaseURL.php;h=be34de30ec5ceb9bb4aa06598d9ae3e1905442d2;hb=ce3b1210640ce653ef91cbf033788474c1f88b0c;hp=c4f6e991b430e5f73f3003e52c7cc8923262494b;hpb=edd4f06ad0084353ba81ba917464bb26e1368a34;p=friendica.git diff --git a/src/Util/BaseURL.php b/src/Util/BaseURL.php index c4f6e991b4..be34de30ec 100644 --- a/src/Util/BaseURL.php +++ b/src/Util/BaseURL.php @@ -137,35 +137,54 @@ class BaseURL */ public function save($hostname = null, $sslPolicy = null, $urlPath = null) { - $success = true; + $currHostname = $this->hostname; + $currSSLPolicy = $this->sslPolicy; + $currURLPath = $this->urlPath; - if (!empty($hostname)) { - $this->hostname = $hostname; - if (!$this->config->set('config', 'hostname', $this->hostname)) { - $success = false; + if (!empty($hostname) && $hostname !== $this->hostname) { + if ($this->config->set('config', 'hostname', $hostname)) { + $this->hostname = $hostname; + } else { + return false; } } - if (isset($sslPolicy)) { - $this->sslPolicy = $sslPolicy; - if (!$this->config->set('system', 'ssl_policy', $this->sslPolicy)) { - $success = false; + if (isset($sslPolicy) && $sslPolicy !== $this->sslPolicy) { + if ($this->config->set('system', 'ssl_policy', $sslPolicy)) { + $this->sslPolicy = $sslPolicy; + } else { + $this->hostname = $currHostname; + $this->config->set('config', 'hostname', $this->hostname); + return false; } } - if (isset($urlPath)) { - $this->urlPath = $urlPath; - if (!$this->config->set('system', 'urlpath', $this->urlPath)) { - $success = false; + if (isset($urlPath) && $urlPath !== $this->urlPath) { + if ($this->config->set('system', 'urlpath', $urlPath)) { + $this->urlPath = $urlPath; + } else { + $this->hostname = $currHostname; + $this->sslPolicy = $currSSLPolicy; + $this->config->set('config', 'hostname', $this->hostname); + $this->config->set('system', 'ssl_policy', $this->sslPolicy); + return false; } } $this->determineBaseUrl(); if (!$this->config->set('system', 'url', $this->url)) { - $success = false; + $this->hostname = $currHostname; + $this->sslPolicy = $currSSLPolicy; + $this->urlPath = $currURLPath; + $this->determineBaseUrl(); + + $this->config->set('config', 'hostname', $this->hostname); + $this->config->set('system', 'ssl_policy', $this->sslPolicy); + $this->config->set('system', 'urlpath', $this->urlPath); + return false; } - return $success; + return true; } /** @@ -266,7 +285,7 @@ class BaseURL if (empty($this->url)) { $this->determineBaseUrl(); - if (!empty($url)) { + if (!empty($this->url)) { $this->config->set('system', 'url', $this->url); } }