From 11f189b037120e5f8fae2ef9eba233a6bfe13c85 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 21 Jan 2019 12:59:28 -0800 Subject: [PATCH] Better fix for #3659 --- ...190218_143000_element_index_settings_uid.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/migrations/m190218_143000_element_index_settings_uid.php b/src/migrations/m190218_143000_element_index_settings_uid.php index 34c2ce7ebf2..b777ea331fc 100644 --- a/src/migrations/m190218_143000_element_index_settings_uid.php +++ b/src/migrations/m190218_143000_element_index_settings_uid.php @@ -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()) @@ -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]; } }