From fb6e0df735e933e5c57a074038e620cea462659e Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 31 Mar 2018 22:53:55 +0300 Subject: [PATCH 1/3] Fixed AggregationInterface use statements --- .../Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php | 2 +- app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php b/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php index f45d9ee223106..1cba6a99a112b 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php @@ -6,7 +6,7 @@ namespace Magento\Cms\Model\ResourceModel\Block\Grid; use Magento\Framework\Api\Search\SearchResultInterface; -use Magento\Framework\Search\AggregationInterface; +use Magento\Framework\Api\Search\AggregationInterface; use Magento\Cms\Model\ResourceModel\Block\Collection as BlockCollection; /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php index 82d436cb6e047..64645e1c03407 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php @@ -6,7 +6,7 @@ namespace Magento\Sales\Model\ResourceModel\Grid; use Magento\Framework\Api\Search\SearchResultInterface; -use Magento\Framework\Search\AggregationInterface; +use Magento\Framework\Api\Search\AggregationInterface; use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; /** From ce903003b935606ad44e30eeb059dc437fb6d637 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 31 Mar 2018 22:54:57 +0300 Subject: [PATCH 2/3] Fixed setAggregations return value --- .../Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php | 1 + .../Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php | 1 + app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php | 1 + 3 files changed, 3 insertions(+) diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php b/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php index 1cba6a99a112b..60e87afc61884 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php @@ -82,6 +82,7 @@ public function getAggregations() public function setAggregations($aggregations) { $this->aggregations = $aggregations; + return $this; } /** diff --git a/app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php b/app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php index c5c43c3120dcc..19f945e5b4637 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Page/Grid/Collection.php @@ -83,6 +83,7 @@ public function getAggregations() public function setAggregations($aggregations) { $this->aggregations = $aggregations; + return $this; } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php index 64645e1c03407..b3bc05056a1b1 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Grid/Collection.php @@ -78,6 +78,7 @@ public function getAggregations() public function setAggregations($aggregations) { $this->aggregations = $aggregations; + return $this; } /** From 4cf7e8b5f0f670d06d30376932de61404a1d0a73 Mon Sep 17 00:00:00 2001 From: Alex Lyzun Date: Fri, 6 Apr 2018 11:59:31 +0200 Subject: [PATCH 3/3] Improve code structure in relation to else / if statements. --- .../Block/System/Messages/UnreadMessagePopup.php | 3 +-- app/code/Magento/AdminNotification/Block/Window.php | 3 +-- .../Model/Export/AdvancedPricing.php | 3 +-- .../Model/Import/AdvancedPricing.php | 3 +-- .../Magento/Analytics/Model/Config/Backend/Enabled.php | 7 +------ .../Magento/Authorization/Model/ResourceModel/Role.php | 3 +-- 6 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php index 7ea0062581467..2d4c7f279f707 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php @@ -77,9 +77,8 @@ public function getPopupTitle() $messageCount = count($this->_messages->getUnread()); if ($messageCount > 1) { return __('You have %1 new system messages', $messageCount); - } else { - return __('You have %1 new system message', $messageCount); } + return __('You have %1 new system message', $messageCount); } /** diff --git a/app/code/Magento/AdminNotification/Block/Window.php b/app/code/Magento/AdminNotification/Block/Window.php index b80e12a8674db..9563626ee2577 100644 --- a/app/code/Magento/AdminNotification/Block/Window.php +++ b/app/code/Magento/AdminNotification/Block/Window.php @@ -98,10 +98,9 @@ protected function _getLatestItem() { if ($this->_latestItem == null) { $items = array_values($this->_criticalCollection->getItems()); + $this->_latestItem = false; if (count($items)) { $this->_latestItem = $items[0]; - } else { - $this->_latestItem = false; } } return $this->_latestItem; diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php index 9047cc6481e62..a92df095036f3 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php @@ -626,9 +626,8 @@ protected function _getCustomerGroupById( ): string { if ($allGroups !== 0) { return ImportAdvancedPricing::VALUE_ALL_GROUPS; - } else { - return $this->_groupRepository->getById($groupId)->getCode(); } + return $this->_groupRepository->getById($groupId)->getCode(); } /** diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php index 0e8acb37104e6..4663aea7a7dfc 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php @@ -482,9 +482,8 @@ protected function deleteProductTierPrices(array $listSku, $table) $this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, 0); return false; } - } else { - return false; } + return false; } /** diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php b/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php index ac97f2a843e61..a5d885c80c3fc 100644 --- a/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php +++ b/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php @@ -67,12 +67,7 @@ public function afterSave() try { if ($this->isValueChanged()) { $enabled = $this->getData('value'); - - if ($enabled) { - $this->subscriptionHandler->processEnabled(); - } else { - $this->subscriptionHandler->processDisabled(); - } + $enabled ? $this->subscriptionHandler->processEnabled() : $this->subscriptionHandler->processDisabled(); } } catch (\Exception $e) { $this->_logger->error($e->getMessage()); diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Role.php b/app/code/Magento/Authorization/Model/ResourceModel/Role.php index 633ae741b44a1..48fe65e7f8b92 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Role.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Role.php @@ -68,6 +68,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role) } if (!$role->getTreeLevel()) { + $treeLevel = 0; if ($role->getPid() > 0) { $select = $this->getConnection()->select()->from( $this->getMainTable(), @@ -79,8 +80,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role) $binds = ['pid' => (int)$role->getPid()]; $treeLevel = $this->getConnection()->fetchOne($select, $binds); - } else { - $treeLevel = 0; } $role->setTreeLevel($treeLevel + 1);