Skip to content

Commit 2aa19a5

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-97210: Add Product by SKU to category causes the browser to hang
1 parent 87d5775 commit 2aa19a5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,19 @@ private function deleteOldUrls(array $urls): void
179179
}
180180
}
181181

182-
$this->connection->query(
183-
$oldUrlsSelect->deleteFromSelect(
184-
$this->resource->getTableName(self::TABLE_NAME)
185-
)
186-
);
182+
// prevent query locking in a case when nothing to delete
183+
$checkOldUrlsSelect = clone $oldUrlsSelect;
184+
$checkOldUrlsSelect->reset(Select::COLUMNS);
185+
$checkOldUrlsSelect->columns('count(*)');
186+
$hasOldUrls = (bool)$this->connection->fetchOne($checkOldUrlsSelect);
187+
188+
if ($hasOldUrls) {
189+
$this->connection->query(
190+
$oldUrlsSelect->deleteFromSelect(
191+
$this->resource->getTableName(self::TABLE_NAME)
192+
)
193+
);
194+
}
187195
}
188196

189197
/**

0 commit comments

Comments
 (0)