Skip to content

Commit

Permalink
Update database when attribute type is changed to integer (#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 19, 2023
1 parent 8c3ae16 commit 0db588a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions system/modules/isotope/library/Isotope/DatabaseUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function autoUpdateTables($arrTables)
if (!empty($arrCommands['ALTER_CHANGE']) && \is_array($arrCommands['ALTER_CHANGE'])) {
foreach ($arrCommands['ALTER_CHANGE'] as $strCommand) {
if (strpos($strCommand, 'ALTER TABLE `' . $strTable . '`') === 0) {
// Try to fix string to int field conversion
if (preg_match('/`([^`]+)` int\(10\) NOT NULL default 0;?$/i', $strCommand, $match)) {
Database::getInstance()->query("UPDATE `$strTable` SET `$match[1]`=0 WHERE `$match[1]`=''");
}

Database::getInstance()->query($strCommand);
}
}
Expand Down

0 comments on commit 0db588a

Please sign in to comment.