Jump to content



Latest News: (loading..)

Issue Information

Issue Confirmations

  • Yes (0)No (0)
Photo

Currency can not be deleted when chained to a language

Posted by cactus on 03 May 2011 - 06:25 PM

Currencies that are chained to a language can not be deleted even if they are not defaults. I was able to successfully remove GBP from the default installation without sample data, the USD was not possible unfortunately. The error presented on doing so gave no clue as to why not.

Analysing the error_log I noticed this:

05/03/2011 20:07:08	PHP Notice: delete from osc_currencies where currencies_id = :currencies_id in S:\oscommerce\osCommerce\OM\Core\PDOStatement.php on line 61
05/03/2011 20:07:08	PHP Warning: PDOStatement::execute(): SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`osc3`.`osc_languages`, CONSTRAINT `idx_languages_currencies_id` FOREIGN KEY (`currencies_id`) REFERENCES `osc_currencies` (`currencies_id`) ON UPDATE CASCADE) in S:\oscommerce\osCommerce\OM\Core\PDOStatement.php on line 58

Upon investigation I discovered the USD was chained to the default (en-us) language and I had to change that, after changing the default currency in the en-us language to EUR I was able to delete USD.

I am not sure what the best way to fix this would be:

1. Give a more informative error
2. Automatically change the currency to the default in the languages that have the value that is to be deleted
3. Something else perhaps...