Page MenuHomePhabricator

D14446.id34913.diff
No OneTemporary

D14446.id34913.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3087,6 +3087,7 @@
'PhabricatorTestApplication' => 'applications/base/controller/__tests__/PhabricatorTestApplication.php',
'PhabricatorTestCase' => 'infrastructure/testing/PhabricatorTestCase.php',
'PhabricatorTestController' => 'applications/base/controller/__tests__/PhabricatorTestController.php',
+ 'PhabricatorTestDaemon' => 'infrastructure/daemon/workers/PhabricatorTestDaemon.php',
'PhabricatorTestDataGenerator' => 'applications/lipsum/generator/PhabricatorTestDataGenerator.php',
'PhabricatorTestNoCycleEdgeType' => 'applications/transactions/edges/PhabricatorTestNoCycleEdgeType.php',
'PhabricatorTestStorageEngine' => 'applications/files/engine/PhabricatorTestStorageEngine.php',
@@ -5906,7 +5907,7 @@
'PhabricatorConfigDatabaseController' => 'PhabricatorConfigController',
'PhabricatorConfigDatabaseIssueController' => 'PhabricatorConfigDatabaseController',
'PhabricatorConfigDatabaseSchema' => 'PhabricatorConfigStorageSchema',
- 'PhabricatorConfigDatabaseSource' => 'PhabricatorConfigProxySource',
+ 'PhabricatorConfigDatabaseSource' => 'PhabricatorConfigSource',
'PhabricatorConfigDatabaseStatusController' => 'PhabricatorConfigDatabaseController',
'PhabricatorConfigDefaultSource' => 'PhabricatorConfigProxySource',
'PhabricatorConfigDictionarySource' => 'PhabricatorConfigSource',
@@ -7316,6 +7317,7 @@
'PhabricatorTestApplication' => 'PhabricatorApplication',
'PhabricatorTestCase' => 'PhutilTestCase',
'PhabricatorTestController' => 'PhabricatorController',
+ 'PhabricatorTestDaemon' => 'PhabricatorDaemon',
'PhabricatorTestDataGenerator' => 'Phobject',
'PhabricatorTestNoCycleEdgeType' => 'PhabricatorEdgeType',
'PhabricatorTestStorageEngine' => 'PhabricatorFileStorageEngine',
diff --git a/src/applications/config/check/PhabricatorDaemonsSetupCheck.php b/src/applications/config/check/PhabricatorDaemonsSetupCheck.php
--- a/src/applications/config/check/PhabricatorDaemonsSetupCheck.php
+++ b/src/applications/config/check/PhabricatorDaemonsSetupCheck.php
@@ -7,7 +7,6 @@
}
protected function executeChecks() {
-
$task_daemon = id(new PhabricatorDaemonLogQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withStatus(PhabricatorDaemonLogQuery::STATUS_RUNNING)
@@ -185,11 +184,6 @@
phutil_tag('tt', array(), 'bin/config'),
phutil_tag('tt', array(), 'phabricator/conf/local/local.json'));
- $this->newIssue('daemons.need-restarting')
- ->setName(pht('Daemons and Web Have Different Config'))
- ->setSummary($summary)
- ->setMessage($message)
- ->addCommand('phabricator/ $ ./bin/phd restart');
break;
}
}
diff --git a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
--- a/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
+++ b/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php
@@ -5,6 +5,7 @@
protected function run() {
do {
PhabricatorCaches::destroyRequestCache();
+ PhabricatorEnv::dropConfigCache();
$tasks = id(new PhabricatorWorkerLeaseQuery())
->setLimit(1)
diff --git a/src/infrastructure/env/PhabricatorConfigDatabaseSource.php b/src/infrastructure/env/PhabricatorConfigDatabaseSource.php
--- a/src/infrastructure/env/PhabricatorConfigDatabaseSource.php
+++ b/src/infrastructure/env/PhabricatorConfigDatabaseSource.php
@@ -1,11 +1,13 @@
<?php
-final class PhabricatorConfigDatabaseSource
- extends PhabricatorConfigProxySource {
+final class PhabricatorConfigDatabaseSource extends PhabricatorConfigSource {
+
+ private $namespace;
public function __construct($namespace) {
- $config = $this->loadConfig($namespace);
- $this->setSource(new PhabricatorConfigDictionarySource($config));
+ $this->namespace = $namespace;
+
+ $this->getAllKeys();
}
public function isWritable() {
@@ -13,10 +15,18 @@
return false;
}
- private function loadConfig($namespace) {
+ public function getKeys(array $keys) {
+ $objects = id(new PhabricatorConfigEntry())->loadAllWhere(
+ 'namespace = %s AND isDeleted = 0 AND configKey IN (%Ls)',
+ $this->namespace,
+ $keys);
+ return mpull($objects, 'getValue', 'getConfigKey');
+ }
+
+ public function getAllKeys() {
$objects = id(new PhabricatorConfigEntry())->loadAllWhere(
'namespace = %s AND isDeleted = 0',
- $namespace);
+ $this->namespace);
return mpull($objects, 'getValue', 'getConfigKey');
}
diff --git a/src/infrastructure/env/PhabricatorConfigLocalSource.php b/src/infrastructure/env/PhabricatorConfigLocalSource.php
--- a/src/infrastructure/env/PhabricatorConfigLocalSource.php
+++ b/src/infrastructure/env/PhabricatorConfigLocalSource.php
@@ -21,13 +21,17 @@
private function loadConfig() {
$path = $this->getConfigPath();
- if (@file_exists($path)) {
- $data = @file_get_contents($path);
- if ($data) {
- $data = json_decode($data, true);
- if (is_array($data)) {
- return $data;
+ if (Filesystem::pathExists($path)) {
+ try {
+ $data = Filesystem::readFile($path);
+ if ($data) {
+ $data = phutil_json_decode($data);
+ if (is_array($data)) {
+ return $data;
+ }
}
+ } catch (FilesystemException $ex) {
+ // Ignore.
}
}
@@ -36,9 +40,9 @@
private function saveConfig() {
$config = $this->getSource()->getAllKeys();
- $json = new PhutilJSON();
- $data = $json->encodeFormatted($config);
- Filesystem::writeFile($this->getConfigPath(), $data);
+ Filesystem::writeFile(
+ $this->getConfigPath(),
+ id(new PhutilJSON())->encodeFormatted($config));
}
private function getConfigPath() {
diff --git a/src/infrastructure/env/PhabricatorConfigProxySource.php b/src/infrastructure/env/PhabricatorConfigProxySource.php
--- a/src/infrastructure/env/PhabricatorConfigProxySource.php
+++ b/src/infrastructure/env/PhabricatorConfigProxySource.php
@@ -10,7 +10,7 @@
final protected function getSource() {
if (!$this->source) {
- throw new Exception(pht('No configuration source set!'));
+ throw new PhutilInvalidStateException('setSource');
}
return $this->source;
}
@@ -20,15 +20,15 @@
return $this;
}
- public function getAllKeys() {
+ final public function getAllKeys() {
return $this->getSource()->getAllKeys();
}
- public function getKeys(array $keys) {
+ final public function getKeys(array $keys) {
return $this->getSource()->getKeys($keys);
}
- public function canWrite() {
+ final public function canWrite() {
return $this->getSource()->canWrite();
}
@@ -42,12 +42,12 @@
return $this;
}
- public function setName($name) {
+ final public function setName($name) {
$this->getSource()->setName($name);
return $this;
}
- public function getName() {
+ final public function getName() {
return $this->getSource()->getName();
}
diff --git a/src/infrastructure/env/PhabricatorConfigSource.php b/src/infrastructure/env/PhabricatorConfigSource.php
--- a/src/infrastructure/env/PhabricatorConfigSource.php
+++ b/src/infrastructure/env/PhabricatorConfigSource.php
@@ -21,13 +21,11 @@
}
public function setKeys(array $keys) {
- throw new Exception(
- pht('This configuration source does not support writes.'));
+ throw new PhutilMethodNotImplementedException();
}
public function deleteKeys(array $keys) {
- throw new Exception(
- pht('This configuration source does not support writes.'));
+ throw new PhutilMethodNotImplementedException();
}
}
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -888,7 +888,7 @@
self::dropConfigCache();
}
- private static function dropConfigCache() {
+ public static function dropConfigCache() {
self::$cache = array();
}

File Metadata

Mime Type
text/plain
Expires
Oct 8 2025, 1:22 PM (13 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8328268
Default Alt Text
D14446.id34913.diff (8 KB)

Event Timeline