From 49cb7e89b26aafe753434255a05f4cd027723119 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sun, 2 Apr 2023 23:14:45 +0100 Subject: [PATCH] Invert the logic to make it easier to understand Signed-off-by: Kamil Tekiela --- libraries/classes/ConfigStorage/Relation.php | 39 ++++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/libraries/classes/ConfigStorage/Relation.php b/libraries/classes/ConfigStorage/Relation.php index f003dcbdbe..92df58cfac 100644 --- a/libraries/classes/ConfigStorage/Relation.php +++ b/libraries/classes/ConfigStorage/Relation.php @@ -1572,29 +1572,28 @@ class Relation // use the possible replaced name first and fallback on the table name // if no replacement exists if (! in_array($tableNameReplacements[$table] ?? $table, $existingTables)) { - if ($create) { - $this->dbi->tryQuery($createQueries[$table], Connection::TYPE_CONTROL); - - $error = $this->dbi->getError(Connection::TYPE_CONTROL); - if ($error) { - $GLOBALS['message'] = $error; - - return; - } - - $foundOne = true; - if (empty($GLOBALS['cfg']['Server'][$feature])) { - // Do not override a user defined value, only fill if empty - $GLOBALS['cfg']['Server'][$feature] = $table; - } + if (! $create) { + continue; } - } else { - $foundOne = true; - if (empty($GLOBALS['cfg']['Server'][$feature])) { - // Do not override a user defined value, only fill if empty - $GLOBALS['cfg']['Server'][$feature] = $table; + + $this->dbi->tryQuery($createQueries[$table], Connection::TYPE_CONTROL); + + $error = $this->dbi->getError(Connection::TYPE_CONTROL); + if ($error) { + $GLOBALS['message'] = $error; + + return; } } + + $foundOne = true; + + // Do not override a user defined value, only fill if empty + if (isset($GLOBALS['cfg']['Server'][$feature]) && $GLOBALS['cfg']['Server'][$feature] !== '') { + continue; + } + + $GLOBALS['cfg']['Server'][$feature] = $table; } if (! $foundOne) {