File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
app/code/Magento/UrlRewrite/Model/Storage Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -179,11 +179,19 @@ private function deleteOldUrls(array $urls): void
179
179
}
180
180
}
181
181
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
+ }
187
195
}
188
196
189
197
/**
You can’t perform that action at this time.
0 commit comments