Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions upgrade/php/ps_915_drop_address_country_index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* For the full copyright and license information, please view the
* LICENSE.md file that was distributed with this source code.
*/

use PrestaShop\Module\AutoUpgrade\Database\DbWrapper;

function ps_915_drop_address_country_index(): bool

Check warning on line 9 in upgrade/php/ps_915_drop_address_country_index.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename function "ps_915_drop_address_country_index" to match the regular expression ^[a-z][a-zA-Z0-9]*$.

See more on https://sonarcloud.io/project/issues?id=PrestaShop_autoupgrade&issues=AZ-qqPNMCMhX7g6B2YS6&open=AZ-qqPNMCMhX7g6B2YS6&pullRequest=1888
{
// Shops that ran into the slow orders grid were told to drop this index by hand, so it can
// already be gone. DROP INDEX on a missing index is an error and MySQL has no IF EXISTS for
// indexes, so check before dropping rather than fail the upgrade on exactly those shops.
$existingIndex = DbWrapper::executeS(
'SHOW INDEX FROM `' . _DB_PREFIX_ . 'address` WHERE `Key_name` = \'id_country\''
);

if (empty($existingIndex)) {
return true;
}

return DbWrapper::execute('ALTER TABLE `' . _DB_PREFIX_ . 'address` DROP INDEX `id_country`');
}
8 changes: 8 additions & 0 deletions upgrade/sql/9.1.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SET SESSION sql_mode='';
SET NAMES 'utf8mb4';

-- https://github.com/PrestaShop/PrestaShop/pull/42162
-- Drop the unused id_country index on address. No query reads it - every core reference joins
-- country on its primary key - and it misleads the optimizer on the orders grid into driving from
-- country_lang instead of orders, turning a 50 row page into a scan with a filesort.
/* PHP:ps_915_drop_address_country_index(); */;