Skip to content

Commit 45ce6e5

Browse files
committed
Merge branch 'MAGETWO-52259' into develop
2 parents fc8a53c + de90990 commit 45ce6e5

File tree

1 file changed

+7
-7
lines changed
  • app/code/Magento/Review/Model/ResourceModel

1 file changed

+7
-7
lines changed

app/code/Magento/Review/Model/ResourceModel/Rating.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ protected function processRatingCodes(\Magento\Framework\Model\AbstractModel $ob
187187
->where('rating_id = :rating_id');
188188
$old = $connection->fetchPairs($select, [':rating_id' => $ratingId]);
189189
$new = array_filter(array_map('trim', $object->getRatingCodes()));
190-
$this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new));
190+
$this->deleteRatingData($ratingId, $table, array_keys(array_diff_assoc($old, $new)));
191191

192192
$insert = [];
193193
foreach (array_diff_assoc($new, $old) as $storeId => $title) {
@@ -210,10 +210,10 @@ protected function processRatingStores(\Magento\Framework\Model\AbstractModel $o
210210
->where('rating_id = :rating_id');
211211
$old = $connection->fetchCol($select, [':rating_id' => $ratingId]);
212212
$new = $object->getStores();
213-
$this->deleteRatingData($ratingId, $table, array_diff_assoc($old, $new));
213+
$this->deleteRatingData($ratingId, $table, array_diff($old, $new));
214214

215215
$insert = [];
216-
foreach (array_keys(array_diff_assoc($new, $old)) as $storeId) {
216+
foreach (array_diff($new, $old) as $storeId) {
217217
$insert[] = ['rating_id' => $ratingId, 'store_id' => (int)$storeId];
218218
}
219219
$this->insertRatingData($table, $insert);
@@ -223,18 +223,18 @@ protected function processRatingStores(\Magento\Framework\Model\AbstractModel $o
223223
/**
224224
* @param int $ratingId
225225
* @param string $table
226-
* @param array $data
226+
* @param array $storeIds
227227
* @return void
228228
*/
229-
protected function deleteRatingData($ratingId, $table, array $data)
229+
protected function deleteRatingData($ratingId, $table, array $storeIds)
230230
{
231-
if (empty($data)) {
231+
if (empty($storeIds)) {
232232
return;
233233
}
234234
$connection = $this->getConnection();
235235
$connection->beginTransaction();
236236
try {
237-
$where = ['rating_id = ?' => $ratingId, 'store_id IN(?)' => array_keys($data)];
237+
$where = ['rating_id = ?' => $ratingId, 'store_id IN(?)' => $storeIds];
238238
$connection->delete($table, $where);
239239
$connection->commit();
240240
} catch (\Exception $e) {

0 commit comments

Comments
 (0)