diff --git a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php index 1296ca62be7ef..056454fbe7903 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php @@ -568,8 +568,7 @@ public function getAttributeRawValue($entityId, $attribute, $store) } if (is_array($attributesData) && sizeof($attributesData) == 1) { - $_data = each($attributesData); - $attributesData = $_data[1]; + $attributesData = array_shift($attributesData); } return $attributesData === false ? false : $attributesData; diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index f623cfc8c7b37..2e41f898f0281 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -803,7 +803,7 @@ public function joinTable($table, $bind, $fields = null, $cond = null, $joinType { $tableAlias = null; if (is_array($table)) { - list($tableAlias, $tableName) = each($table); + list($tableAlias, $tableName) = [key($table), current($table)]; } else { $tableName = $table; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php index caa0b2734bb20..785fa042193a4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php @@ -160,4 +160,29 @@ public function addAttributeToSortDataProvider() ] ]; } + + /** + * Checks a case if table for join specified as an array. + * + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function testJoinTable() + { + $this->collection->joinTable( + ['alias' => 'url_rewrite'], + 'entity_id = entity_id', + ['request_path'], + '{{table}}.entity_type = \'product\'', + 'left' + ); + $sql = (string) $this->collection->getSelect(); + $productTable = $this->collection->getTable('catalog_product_entity'); + $urlRewriteTable = $this->collection->getTable('url_rewrite'); + + $expected = 'SELECT `e`.*, `alias`.`request_path` FROM `' . $productTable . '` AS `e`' + . ' LEFT JOIN `' . $urlRewriteTable . '` AS `alias` ON (alias.entity_id =e.entity_id)' + . ' AND (alias.entity_type = \'product\')'; + + self::assertContains($expected, str_replace(PHP_EOL, '', $sql)); + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php new file mode 100644 index 0000000000000..7954e2c36227f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php @@ -0,0 +1,52 @@ +objectManager = Bootstrap::getObjectManager(); + + $this->model = $this->objectManager->get(Product::class); + } + + /** + * Checks a possibility to retrieve product raw attribute value. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testGetAttributeRawValue() + { + $sku = 'simple'; + $attribute = 'name'; + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $product = $productRepository->get($sku); + + $actual = $this->model->getAttributeRawValue($product->getId(), $attribute, null); + self::assertEquals($product->getName(), $actual); + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php index deed829838936..e62c4112553b6 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/CircularDependencyTest.php @@ -44,9 +44,9 @@ protected function buildModulesDependencies() $moduleName = str_replace('/', '_', $moduleName[1]); $config = simplexml_load_file($configFile); $result = $config->xpath("/config/module/depends/module") ?: []; - while (list(, $node) = each($result)) { + foreach ($result as $node) { /** @var \SimpleXMLElement $node */ - $this->moduleDependencies[$moduleName][] = (string)$node['name']; + $this->moduleDependencies[$moduleName][] = (string) $node['name']; } } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php index dfe43224e7530..cedb4ae0bf0dc 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php @@ -394,7 +394,8 @@ public function testComponentPathsInRoot() "If there are any component paths specified, then they must be reflected in 'replace' section" ); $flat = $this->getFlatPathsInfo(self::$rootJson['extra']['component_paths']); - while (list(, list($component, $path)) = each($flat)) { + foreach ($flat as $item) { + list($component, $path) = $item; $this->assertFileExists( self::$root . '/' . $path, "Missing or invalid component path: {$component} -> {$path}" diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index fe211a02d393e..105d44d6016c5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2522,5 +2522,6 @@ ['getBunchImages', 'Magento\CatalogImportExport\Model\Import\Product'], ['_isAttributeValueEmpty', 'Magento\Catalog\Model\ResourceModel\AbstractResource'], ['var_dump', ''], + ['each', ''], ['isOrderIncrementIdUsed', 'Magento\Quote\Model\ResourceModel\Quote', 'Magento\Sales\Model\OrderIncrementIdChecker::isIncrementIdUsed'] ]; diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 60cf85efc40ca..63584151fd7ba 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -337,7 +337,8 @@ public function install($request) $this->log->log('Starting Magento installation:'); - while (list(, list($message, $method, $params)) = each($script)) { + foreach ($script as $item) { + list($message, $method, $params) = $item; $this->log->log($message); call_user_func_array([$this, $method], $params); $this->logProgress();