mirror of
https://github.com/friendica/friendica
synced 2025-01-03 20:02:19 +00:00
Reduce config->set() load for worker executions
This commit is contained in:
parent
0ab5fed64c
commit
4c2fc3ea38
2 changed files with 39 additions and 17 deletions
|
@ -175,6 +175,7 @@ class BaseURL
|
||||||
$currHostname = $this->hostname;
|
$currHostname = $this->hostname;
|
||||||
$currSSLPolicy = $this->sslPolicy;
|
$currSSLPolicy = $this->sslPolicy;
|
||||||
$currURLPath = $this->urlPath;
|
$currURLPath = $this->urlPath;
|
||||||
|
$currUrl = $this->url;
|
||||||
|
|
||||||
if (!empty($hostname) && $hostname !== $this->hostname) {
|
if (!empty($hostname) && $hostname !== $this->hostname) {
|
||||||
if ($this->config->set('config', 'hostname', $hostname)) {
|
if ($this->config->set('config', 'hostname', $hostname)) {
|
||||||
|
@ -207,16 +208,18 @@ class BaseURL
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->determineBaseUrl();
|
$this->determineBaseUrl();
|
||||||
if (!$this->config->set('system', 'url', $this->url)) {
|
if ($this->url !== $currUrl) {
|
||||||
$this->hostname = $currHostname;
|
if (!$this->config->set('system', 'url', $this->url)) {
|
||||||
$this->sslPolicy = $currSSLPolicy;
|
$this->hostname = $currHostname;
|
||||||
$this->urlPath = $currURLPath;
|
$this->sslPolicy = $currSSLPolicy;
|
||||||
$this->determineBaseUrl();
|
$this->urlPath = $currURLPath;
|
||||||
|
$this->determineBaseUrl();
|
||||||
|
|
||||||
$this->config->set('config', 'hostname', $this->hostname);
|
$this->config->set('config', 'hostname', $this->hostname);
|
||||||
$this->config->set('system', 'ssl_policy', $this->sslPolicy);
|
$this->config->set('system', 'ssl_policy', $this->sslPolicy);
|
||||||
$this->config->set('system', 'urlpath', $this->urlPath);
|
$this->config->set('system', 'urlpath', $this->urlPath);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -231,6 +231,21 @@ class BaseURLTest extends MockedTest
|
||||||
public function dataSave()
|
public function dataSave()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'no_change' => [
|
||||||
|
'input' => [
|
||||||
|
'hostname' => 'friendica.local',
|
||||||
|
'urlPath' => 'path',
|
||||||
|
'sslPolicy' => BaseURL::SSL_POLICY_FULL,
|
||||||
|
'url' => 'https://friendica.local/path',
|
||||||
|
'force_ssl' => true,
|
||||||
|
],
|
||||||
|
'save' => [
|
||||||
|
'hostname' => 'friendica.local',
|
||||||
|
'urlPath' => 'path',
|
||||||
|
'sslPolicy' => BaseURL::SSL_POLICY_FULL,
|
||||||
|
],
|
||||||
|
'url' => 'https://friendica.local/path',
|
||||||
|
],
|
||||||
'default' => [
|
'default' => [
|
||||||
'input' => [
|
'input' => [
|
||||||
'hostname' => 'friendica.old',
|
'hostname' => 'friendica.old',
|
||||||
|
@ -324,19 +339,21 @@ class BaseURLTest extends MockedTest
|
||||||
|
|
||||||
$baseUrl = new BaseURL($configMock, []);
|
$baseUrl = new BaseURL($configMock, []);
|
||||||
|
|
||||||
if (isset($save['hostname'])) {
|
if (isset($save['hostname']) && ($save['hostname'] !== $input['hostname'])) {
|
||||||
$configMock->shouldReceive('set')->with('config', 'hostname', $save['hostname'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('config', 'hostname', $save['hostname'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($save['urlPath'])) {
|
if (isset($save['urlPath']) && ($save['urlPath'] !== $input['urlPath'])) {
|
||||||
$configMock->shouldReceive('set')->with('system', 'urlpath', $save['urlPath'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('system', 'urlpath', $save['urlPath'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($save['sslPolicy'])) {
|
if (isset($save['sslPolicy']) && ($save['sslPolicy'] !== $input['sslPolicy'])) {
|
||||||
$configMock->shouldReceive('set')->with('system', 'ssl_policy', $save['sslPolicy'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('system', 'ssl_policy', $save['sslPolicy'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
$configMock->shouldReceive('set')->with('system', 'url', $url)->andReturn(true)->once();
|
if ($input['url'] !== $url) {
|
||||||
|
$configMock->shouldReceive('set')->with('system', 'url', $url)->andReturn(true)->once();
|
||||||
|
}
|
||||||
|
|
||||||
$baseUrl->save($save['hostname'], $save['sslPolicy'], $save['urlPath']);
|
$baseUrl->save($save['hostname'], $save['sslPolicy'], $save['urlPath']);
|
||||||
|
|
||||||
|
@ -362,19 +379,21 @@ class BaseURLTest extends MockedTest
|
||||||
|
|
||||||
$baseUrl = new BaseURL($configMock, []);
|
$baseUrl = new BaseURL($configMock, []);
|
||||||
|
|
||||||
if (isset($save['hostname'])) {
|
if (isset($save['hostname']) && ($save['hostname'] !== $input['hostname'])) {
|
||||||
$configMock->shouldReceive('set')->with('config', 'hostname', $save['hostname'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('config', 'hostname', $save['hostname'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($save['urlPath'])) {
|
if (isset($save['urlPath']) && ($save['urlPath'] !== $input['urlPath'])) {
|
||||||
$configMock->shouldReceive('set')->with('system', 'urlpath', $save['urlPath'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('system', 'urlpath', $save['urlPath'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($save['sslPolicy'])) {
|
if (isset($save['sslPolicy']) && ($save['sslPolicy'] !== $input['sslPolicy'])) {
|
||||||
$configMock->shouldReceive('set')->with('system', 'ssl_policy', $save['sslPolicy'])->andReturn(true)->once();
|
$configMock->shouldReceive('set')->with('system', 'ssl_policy', $save['sslPolicy'])->andReturn(true)->once();
|
||||||
}
|
}
|
||||||
|
|
||||||
$configMock->shouldReceive('set')->with('system', 'url', $url)->andReturn(true)->once();
|
if ($input['url'] !== $url) {
|
||||||
|
$configMock->shouldReceive('set')->with('system', 'url', $url)->andReturn(true)->once();
|
||||||
|
}
|
||||||
|
|
||||||
$baseUrl->saveByURL($url);
|
$baseUrl->saveByURL($url);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue