Skip to content

Commit efce35c

Browse files
authored
Merge pull request #48 from Caprico85/magento2
Use collation safe comparison for config and attribute value cleanup
2 parents 6dad086 + 1b02876 commit efce35c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Console/Command/RestoreUseDefaultConfigValueCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public function execute(InputInterface $input, OutputInterface $output)
5454
$db = $resConnection->getConnection();
5555
$configData = $db->fetchAll('SELECT DISTINCT path, value FROM ' . $db->getTableName('core_config_data') . ' WHERE scope_id = 0');
5656
foreach ($configData as $config) {
57-
$count = $db->fetchOne('SELECT COUNT(*) FROM ' . $db->getTableName('core_config_data') .' WHERE path = ? AND value = ?', array($config['path'], $config['value']));
57+
$count = $db->fetchOne('SELECT COUNT(*) FROM ' . $db->getTableName('core_config_data') .' WHERE path = ? AND BINARY value = ?', array($config['path'], $config['value']));
5858
if ($count > 1) {
5959
$output->writeln('Config path ' . $config['path'] . ' with value ' . $config['value']. ' has ' . $count . ' values; deleting non-default values');
6060
if (!$isDryRun) {
61-
$db->query('DELETE FROM ' . $db->getTableName('core_config_data') . ' WHERE path = ? AND value = ? AND scope_id != ?', array($config['path'], $config['value'], 0));
61+
$db->query('DELETE FROM ' . $db->getTableName('core_config_data') . ' WHERE path = ? AND BINARY value = ? AND scope_id != ?', array($config['path'], $config['value'], 0));
6262
}
6363
$removedConfigValues += ($count-1);
6464
}

Console/Command/RestoreUseDefaultValueCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function execute(InputInterface $input, OutputInterface $output)
7979
// Select the global value if it's the same as the non-global value
8080
$results = $db->fetchAll(
8181
'SELECT * FROM ' . $fullTableName
82-
. ' WHERE attribute_id = ? AND store_id = ? AND ' . $column . ' = ? AND value = ?',
82+
. ' WHERE attribute_id = ? AND store_id = ? AND ' . $column . ' = ? AND BINARY value = ?',
8383
array($row['attribute_id'], 0, $row[$column], $row['value'])
8484
);
8585

0 commit comments

Comments
 (0)