From: skodak Date: Wed, 3 Jun 2009 20:16:20 +0000 (+0000) Subject: MDL-18293 $DB->somethiong is using exceptions, no need for ifs there, removing useles... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a8d6ef8c6c6004fda82dd0e4446faa504e882361;p=moodle.git MDL-18293 $DB->somethiong is using exceptions, no need for ifs there, removing useless strings --- diff --git a/course/index.php b/course/index.php index df064a7253..e8de6cac0a 100644 --- a/course/index.php +++ b/course/index.php @@ -151,9 +151,7 @@ // Try and make one $tempcat = new object(); $tempcat->name = get_string('miscellaneous'); - if (!$tempcat->id = $DB->insert_record('course_categories', $tempcat)) { - print_error('cannotsetupcategory'); - } + $tempcat->id = $DB->insert_record('course_categories', $tempcat); $tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id); mark_context_dirty('/'.SYSCONTEXTID); fix_course_sortorder(); // Required to build course_categories.depth and .path. diff --git a/course/request.php b/course/request.php index aaa8050954..73eb6a28c6 100644 --- a/course/request.php +++ b/course/request.php @@ -62,9 +62,7 @@ /// Record the request. $data->requester = $USER->id; - if (!$DB->insert_record('course_request', $data)) { - print_error('errorsavingrequest', '', $returnurl); - } + $DB->insert_record('course_request', $data); /// Notify the admin if required. if ($CFG->courserequestnotify) { diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index d62a59071e..1a1a58730a 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -80,7 +80,6 @@ $string['cannotimportformat'] = 'Sorry, importing this format is not yet impleme $string['cannotinsertgrade'] = 'Cannot insert grade item without course id!'; $string['cannotinsertrate'] = 'Could not insert a new rating ($a->id = $a->rating)'; $string['cannotinsertrecord'] = 'Could not insert new record ID $a'; -$string['cannotinsertkey'] = 'Cannot insert new key'; $string['cannotmailconfirm'] = 'Error sending password change confirmation email'; $string['cannotmanualctrack'] = 'Activity does not provide manual completion tracking'; $string['cannotmapfield'] = 'Mapping collision detected - two fields maps to the same grade item $a'; @@ -120,7 +119,6 @@ $string['cannotsetpassword'] = 'Could not set user password!'; $string['cannotsetprefgrade'] = 'Could not set preference aggregationview to $a for this grade category'; $string['cannotsettheme'] = 'Could not set the theme!'; $string['cannotsetupblock'] = 'Blocks tables could NOT be set up successfully!'; -$string['cannotsetupcategory'] = 'Serious error! Could not set up a default course category!'; $string['cannotsetupcapforplugin'] = 'Could not set up the capabilities for $a'; $string['cannotsetupcapformod'] = 'Could not set up the capabilities for $a'; $string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in category $a.'; diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php index f5284e75ee..e1c4875396 100644 --- a/lang/en_utf8/forum.php +++ b/lang/en_utf8/forum.php @@ -46,9 +46,6 @@ $string['cannotsubscribe'] = 'Sorry, but you must be a group member to subscribe $string['cannotsplit'] = 'Discussions from this forum cannot be split'; $string['cannotunsubscribe'] = 'Could not unsubscribe you from that forum'; $string['cannotupdatecoursemoudle'] = 'Could not update course module with section id'; -$string['cannotupdatediscussion'] = 'Could not update the discussion'; -$string['cannotupdateforum'] = 'Can not update forum'; -$string['cannotupdatefirstpost'] = 'Could not update the first post'; $string['cannotupdatepost'] = 'You can not update this post'; $string['cannotremovesubscriber'] = 'Could not remove subscriber with id $a from this forum!'; $string['cannotreply'] = 'You cannot reply to this post'; diff --git a/lib/datalib.php b/lib/datalib.php index 5ae2fcb272..1b7177b560 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1313,9 +1313,7 @@ function get_course_category($catid=0) { $cat->depth = 1; $cat->sortorder = MAX_COURSES_IN_CATEGORY; $cat->timemodified = time(); - if (!$catid = $DB->insert_record('course_categories', $cat)) { - print_error('cannotsetupcategory', 'error'); - } + $catid = $DB->insert_record('course_categories', $cat); // make sure category context exists get_context_instance(CONTEXT_COURSECAT, $catid); mark_context_dirty('/'.SYSCONTEXTID); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c48e438f44..756748ee1f 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2378,11 +2378,7 @@ function create_user_key($script, $userid, $instance=null, $iprestriction=null, // must be unique $key->value = md5($userid.'_'.time().random_string(40)); } - - if (!$DB->insert_record('user_private_key', $key)) { - print_error('cannotinsertkey'); - } - + $DB->insert_record('user_private_key', $key); return $key->value; } diff --git a/lib/questionlib.php b/lib/questionlib.php index 32a4849ec8..d93bba5a09 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -2062,9 +2062,7 @@ function question_new_attempt_uniqueid($modulename='quiz') { $attempt = new stdClass; $attempt->modulename = $modulename; - if (!$id = $DB->insert_record('question_attempts', $attempt)) { - print_error('cannotcreate', 'question'); - } + $id = $DB->insert_record('question_attempts', $attempt); return $id; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 7c9b3f8393..d617fd9431 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -184,20 +184,12 @@ function forum_update_instance($forum) { $post->message = $forum->intro; $post->modified = $forum->timemodified; - if (! $DB->update_record('forum_posts', ($post))) { - print_error('cannotupdatefirstpost', 'forum'); - } - + $DB->update_record('forum_posts', $post); $discussion->name = $forum->name; - - if (! $DB->update_record('forum_discussions', ($discussion))) { - print_error('cannotupdatediscussion', 'forum'); - } + $DB->update_record('forum_discussions', $discussion); } - if (!$DB->update_record('forum', $forum)) { - print_error('cannotupdateforum', 'forum'); - } + $DB->update_record('forum', $forum); forum_grade_item_update($forum); diff --git a/mod/forum/post.php b/mod/forum/post.php index 1951b3cec0..6118a3fcea 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -389,9 +389,7 @@ $newpost->parent = 0; $newpost->subject = $name; - if (!$DB->update_record("forum_posts", $newpost)) { - print_error('cannotupdatediscussion', 'forum'); - } + $DB->update_record("forum_posts", $newpost); forum_change_discussionid($post->id, $newid);