From f6949ddb95376f147332dfd957bd7266b1ed1c0b Mon Sep 17 00:00:00 2001 From: skodak Date: Fri, 17 Apr 2009 08:05:55 +0000 Subject: [PATCH] MDL-18887 using exceptions instead of @ for ignoring of db update/insert failure --- lib/weblib.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 81cd07afc3..252d6e5c4a 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1379,17 +1379,23 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL $newcacheitem->timemodified = time(); if ($oldcacheitem) { // See bug 4677 for discussion $newcacheitem->id = $oldcacheitem->id; - @$DB->update_record('cache_text', $newcacheitem); // Update existing record in the cache table - // It's unlikely that the cron cache cleaner could have - // deleted this entry in the meantime, as it allows - // some extra time to cover these cases. + try { + $DB->update_record('cache_text', $newcacheitem); // Update existing record in the cache table + } catch (dml_exception $e) { + // It's unlikely that the cron cache cleaner could have + // deleted this entry in the meantime, as it allows + // some extra time to cover these cases. + } } else { - @$DB->insert_record('cache_text', $newcacheitem); // Insert a new record in the cache table - // Again, it's possible that another user has caused this - // record to be created already in the time that it took - // to traverse this function. That's OK too, as the - // call above handles duplicate entries, and eventually - // the cron cleaner will delete them. + try { + $DB->insert_record('cache_text', $newcacheitem); // Insert a new record in the cache table + } catch (dml_exception $e) { + // Again, it's possible that another user has caused this + // record to be created already in the time that it took + // to traverse this function. That's OK too, as the + // call above handles duplicate entries, and eventually + // the cron cleaner will delete them. + } } } -- 2.39.5