diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-10-02 23:55:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-02 23:55:17 +0300 |
commit | 458fd5ca7ad1224c9fd5d49b8c9d6628b3648bd7 (patch) | |
tree | 8f72f6662e0d8af804238ff31e47e88b0e2b647c /core/Option.php | |
parent | 9e34ecd4ff43d19dee4b4e881545302d07887bb7 (diff) |
Ignore option inserts if they fail (#14931)
Problem I'm having is that I'm using a different DB backend which logs/shows errors in their DB layer. In this case what happens is that we're often calling `Option::set()` and the value doesn't actually change. In this case because no row changed, the update `$result` will be `0` and therefore it will try to insert the value which will fail because of duplicate entry.
I know we're catching the exception but in this case we can as well IGNORE any failure when we catch any exception anyway. This way there will be no more errors shown in the UI when using a different DB layer. I know the same problem can happen in other queries we do as well but it's particularly annoying with the option queries currently.
Diffstat (limited to 'core/Option.php')
-rw-r--r-- | core/Option.php | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/Option.php b/core/Option.php index 42e1c73abd..0357865840 100644 --- a/core/Option.php +++ b/core/Option.php @@ -195,7 +195,7 @@ class Option if (! $rowsUpdated) { try { - $sql = 'INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' . + $sql = 'INSERT IGNORE INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' . 'VALUES (?, ?, ?) '; $bind = array($name, $value, $autoLoad); |