Skip to content

Commit

Permalink
Better fix for #3659
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Jan 21, 2019
1 parent c0d7f64 commit 11f189b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/migrations/m190218_143000_element_index_settings_uid.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function safeUp()
->pairs();

$this->_elementData[Asset::class] = (new Query())
->select(['folders.id folderId', 'volumes.uid volumeUid'])
->from([Table::VOLUMES . ' volumes'])
->innerJoin([Table::VOLUMEFOLDERS . ' folders'], '[[volumes.id]] = [[folders.volumeId]]')
->select(['id', 'uid'])
->from([Table::VOLUMEFOLDERS])
->where(['parentId' => null])
->pairs();

$rows = (new Query())
Expand Down Expand Up @@ -113,16 +113,13 @@ private function _normalizeSourceKey(string $sourceKey, $elementClass): string
return $sourceKey;
}

$parts = explode(':', $sourceKey);
$parts = explode(':', $sourceKey, 2);
$id = $parts[1];

if ($elementClass === Asset::class) {
$replace = 'volume';
} else {
$replace = $this->_elements[$elementClass];
if (!isset($this->_elementData[$elementClass][$id])) {
return $sourceKey;
}


return array_key_exists($id, $this->_elementData[$elementClass]) ? $replace.':'.$this->_elementData[$elementClass][$id] : $sourceKey;
return $this->_elements[$elementClass] . ':' . $this->_elementData[$elementClass][$id];
}
}

0 comments on commit 11f189b

Please # to comment.