*/
public function getKeys(string $app): array {
$this->assertParams($app);
- $this->loadConfigAll();
+ $this->loadConfigAll($app);
$keys = array_merge(array_keys($this->fastCache[$app] ?? []), array_keys($this->lazyCache[$app] ?? []));
sort($keys);
*/
public function hasKey(string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($app, $key);
- $this->loadConfig($lazy);
+ $this->loadConfig($app, $lazy);
if ($lazy === null) {
$appCache = $this->getAllValues($app);
*/
public function isSensitive(string $app, string $key, ?bool $lazy = false): bool {
$this->assertParams($app, $key);
- $this->loadConfig($lazy);
+ $this->loadConfig(null, $lazy);
if (!isset($this->valueTypes[$app][$key])) {
throw new AppConfigUnknownKeyException('unknown config key');
public function getAllValues(string $app, string $prefix = '', bool $filtered = false): array {
$this->assertParams($app, $prefix);
// if we want to filter values, we need to get sensitivity
- $this->loadConfigAll();
+ $this->loadConfigAll($app);
// array_merge() will remove numeric keys (here config keys), so addition arrays instead
$values = $this->formatAppValues($app, ($this->fastCache[$app] ?? []) + ($this->lazyCache[$app] ?? []));
$values = array_filter(
*/
public function searchValues(string $key, bool $lazy = false, ?int $typedAs = null): array {
$this->assertParams('', $key, true);
- $this->loadConfig($lazy);
+ $this->loadConfig(null, $lazy);
/** @var array<array-key, array<array-key, mixed>> $cache */
if ($lazy) {
int $type,
): string {
$this->assertParams($app, $key, valueType: $type);
- $this->loadConfig($lazy);
+ $this->loadConfig($app, $lazy);
/**
* We ignore check if mixed type is requested.
*/
public function getValueType(string $app, string $key, ?bool $lazy = null): int {
$this->assertParams($app, $key);
- $this->loadConfig($lazy);
+ $this->loadConfig($app, $lazy);
if (!isset($this->valueTypes[$app][$key])) {
throw new AppConfigUnknownKeyException('unknown config key');
int $type,
): bool {
$this->assertParams($app, $key);
- $this->loadConfig($lazy);
+ $this->loadConfig(null, $lazy);
$sensitive = $this->isTyped(self::VALUE_SENSITIVE, $type);
$inserted = $refreshCache = false;
}
}
- private function loadConfigAll(): void {
- $this->loadConfig(null);
+ private function loadConfigAll(?string $app = null): void {
+ $this->loadConfig($app, null);
}
/**
*
* @param bool|null $lazy set to TRUE to load config set as lazy loaded, set to NULL to load all config
*/
- private function loadConfig(?bool $lazy = false): void {
+ private function loadConfig(?string $app = null, ?bool $lazy = false): void {
if ($this->isLoaded($lazy)) {
return;
}
- if (($lazy ?? true) !== false) { // if lazy is null or true, we debug log
- $this->logger->debug('The loading of lazy AppConfig values have been requested', ['exception' => new \RuntimeException('ignorable exception')]);
+ // if lazy is null or true, we debug log
+ if (($lazy ?? true) !== false && $app !== null) {
+ $exception = new \RuntimeException('The loading of lazy AppConfig values have been triggered by app "' . $app . '"');
+ $this->logger->debug($exception->getMessage(), ['exception' => $exception, 'app' => $app]);
}
$qb = $this->connection->getQueryBuilder();
$qb->from('appconfig');
/**
- * The use of $this->>migrationCompleted is only needed to manage the
+ * The use of $this->migrationCompleted is only needed to manage the
* database during the upgrading process to nc29.
*/
if (!$this->migrationCompleted) {
}
$this->migrationCompleted = false;
- $this->loadConfig($lazy);
+ $this->loadConfig($app, $lazy);
return;
}
* not exist the default value will be returned
*/
public function getValue($app, $key, $default = null) {
- $this->loadConfig();
+ $this->loadConfig($app);
return $this->fastCache[$app][$key] ?? $default;
}