Fixes #15353: Remove side effect of ActiveQuery::getTablesUsedInFrom() introduced in 2.0.13

This commit is contained in:
Alexander
2018-01-15 12:02:28 +02:00
committed by Alexander Makarov
parent 6c0540aa2d
commit f8990ac97a
4 changed files with 22 additions and 2 deletions

View File

@ -809,7 +809,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
public function getTablesUsedInFrom()
{
if (empty($this->from)) {
$this->from = [$this->getPrimaryTableName()];
return $this->cleanUpTableNames([$this->getPrimaryTableName()]);
}
return parent::getTablesUsedInFrom();

View File

@ -479,7 +479,18 @@ class Query extends Component implements QueryInterface
throw new InvalidConfigException(gettype($this->from) . ' in $from is not supported.');
}
// Clean up table names and aliases
return $this->cleanUpTableNames($tableNames);
}
/**
* Clean up table names and aliases
* Both aliases and names are enclosed into {{ and }}.
* @param array $tableNames non-empty array
* @return string[] table names indexed by aliases
* @since 2.0.14
*/
protected function cleanUpTableNames($tableNames)
{
$cleanedUpTableNames = [];
foreach ($tableNames as $alias => $tableName) {
if (is_string($tableName) && !is_string($alias)) {