Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 7 additions & 42 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ class AppConfig implements IAppConfig {
/** @var array<array-key, array{entries: array<array-key, ConfigLexiconEntry>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */
private array $configLexiconDetails = [];

/**
* $migrationCompleted is only needed to manage the previous structure
* of the database during the upgrading process to nc29.
*
* only when upgrading from a version prior 28.0.2
*
* @TODO: remove this value in Nextcloud 30+
*/
private bool $migrationCompleted = true;

public function __construct(
protected IDBConnection $connection,
protected LoggerInterface $logger,
Expand Down Expand Up @@ -1212,41 +1202,16 @@ private function loadConfig(?string $app = null, ?bool $lazy = false): void {
$qb = $this->connection->getQueryBuilder();
$qb->from('appconfig');

/**
* The use of $this->migrationCompleted is only needed to manage the
* database during the upgrading process to nc29.
*/
if (!$this->migrationCompleted) {
$qb->select('appid', 'configkey', 'configvalue');
} else {
// we only need value from lazy when loadConfig does not specify it
$qb->select('appid', 'configkey', 'configvalue', 'type');

if ($lazy !== null) {
$qb->where($qb->expr()->eq('lazy', $qb->createNamedParameter($lazy ? 1 : 0, IQueryBuilder::PARAM_INT)));
} else {
$qb->addSelect('lazy');
}
}

try {
$result = $qb->executeQuery();
} catch (DBException $e) {
/**
* in case of issue with field name, it means that migration is not completed.
* Falling back to a request without select on lazy.
* This whole try/catch and the migrationCompleted variable can be removed in NC30.
*/
if ($e->getReason() !== DBException::REASON_INVALID_FIELD_NAME) {
throw $e;
}

$this->migrationCompleted = false;
$this->loadConfig($app, $lazy);
// we only need value from lazy when loadConfig does not specify it
$qb->select('appid', 'configkey', 'configvalue', 'type');

return;
if ($lazy !== null) {
$qb->where($qb->expr()->eq('lazy', $qb->createNamedParameter($lazy ? 1 : 0, IQueryBuilder::PARAM_INT)));
} else {
$qb->addSelect('lazy');
}

$result = $qb->executeQuery();
$rows = $result->fetchAll();
foreach ($rows as $row) {
// most of the time, 'lazy' is not in the select because its value is already known
Expand Down
Loading