diff options
Diffstat (limited to 'core/DataAccess/LogQueryBuilder/JoinGenerator.php')
-rw-r--r-- | core/DataAccess/LogQueryBuilder/JoinGenerator.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/DataAccess/LogQueryBuilder/JoinGenerator.php b/core/DataAccess/LogQueryBuilder/JoinGenerator.php index 0324bff9b5..a7f8b5499f 100644 --- a/core/DataAccess/LogQueryBuilder/JoinGenerator.php +++ b/core/DataAccess/LogQueryBuilder/JoinGenerator.php @@ -62,6 +62,38 @@ class JoinGenerator } } } + + foreach ($this->tables as $index => $table) { + if (is_array($table)) { + if (!isset($table['tableAlias'])) { + $tableName = $table['table']; + $numTables = count($this->tables); + for ($j = $index + 1; $j < $numTables; $j++) { + if (!isset($this->tables[$j])) { + continue; + } + + $tableOther = $this->tables[$j]; + if (is_string($tableOther) && $tableOther === $tableName) { + unset($this->tables[$j]); + } + } + } + } elseif (is_string($table)) { + $numTables = count($this->tables); + + for ($j = $index + 1; $j < $numTables; $j++) { + if (isset($this->tables[$j]) && is_array($this->tables[$j]) && !isset($this->tables[$j]['tableAlias'])) { + $tableOther = $this->tables[$j]; + if ($table === $tableOther['table']) { + $message = sprintf('Please reorganize the joined tables as the table %s in %s cannot be joined correctly. We recommend to join tables with arrays first. %s', $table, json_encode($this->tables), json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10))); + throw new Exception($message); + } + } + + } + } + } } /** |