From: skodak Date: Sat, 13 Jun 2009 17:35:10 +0000 (+0000) Subject: MDL-18293 removed obsoleted checking of return values from insert and update_record... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9d7493399decf067b129a1e352e6c2bb6d1eb070;p=moodle.git MDL-18293 removed obsoleted checking of return values from insert and update_record + unused strings cleanup --- diff --git a/blocks/rss_client/block_rss_client_action.php b/blocks/rss_client/block_rss_client_action.php index c37e71b86f..3f727dc8f5 100644 --- a/blocks/rss_client/block_rss_client_action.php +++ b/blocks/rss_client/block_rss_client_action.php @@ -172,9 +172,6 @@ if ($act == 'updfeed') { } $rssid = $DB->insert_record('block_rss_client', $dataobject); - if (!$rssid) { - print_error('updatersserror', 'error', '', $url); - } // By capturing the output from fetch_rss this way // error messages do not display and clutter up the moodle interface diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index 24d578a52e..d9fac63da2 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -268,7 +268,6 @@ $string['type'] = 'Field type'; $string['undefinedprocessactionmethod'] = 'No action method defined in Data_Preset to handle action \"$a\".'; $string['unsupportedexport'] = '($a->fieldtype) cannot be exported.'; $string['updatefield'] = 'Update an existing field'; -$string['updatingerror'] = 'There was an error updating the database'; $string['uploadfile'] = 'Upload file'; $string['uploadrecords'] = 'Upload entries from a file'; $string['url'] = 'Url'; diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index abcb5c0486..af0f09d9ad 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -464,7 +464,6 @@ $string['usernotupdatedadmin'] = 'Cannot update admin accounts'; $string['usernotupdatederror'] = 'User not updated - error'; $string['usernotupdatednotexists'] = 'User not updated - does not exist'; $string['userselectortoomany'] = 'user_selector got more than one selected user, even though multiselect is false.'; -$string['updatersserror'] = 'There was an error trying to update RSS feed with id: $a'; $string['upgraderunning'] = 'Site is being upgraded, please retry later.'; $string['younotteacher'] = 'You are not a teacher!'; $string['wrongcall'] = 'This script is called wrongly'; diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php index e1c4875396..93869e4ec5 100644 --- a/lang/en_utf8/forum.php +++ b/lang/en_utf8/forum.php @@ -38,7 +38,6 @@ $string['cannotadddiscussionall'] = 'You do not have permission to add a new dis $string['cannotaddsubscriber'] = 'Could not add subscriber with id $a to this forum!'; $string['cannotcreateinstanceforteacher'] = 'Could not create new course module instance for the teacher forum'; $string['cannotcreatediscussion'] = 'Could not create new discussion'; -$string['cannotconvertteachertogeneral'] = 'Could not change forum from type teacher to type general'; $string['cannotdeleteforummodule'] = 'You can not delete the forum module.'; $string['cannotdeletepost'] = 'You can\'t delete this post!'; $string['cannoteditposts'] = 'You can\'t edit other people\'s posts!'; diff --git a/lang/en_utf8/glossary.php b/lang/en_utf8/glossary.php index c426781ce6..5ff52caf21 100644 --- a/lang/en_utf8/glossary.php +++ b/lang/en_utf8/glossary.php @@ -23,7 +23,6 @@ $string['attachment'] = 'Attachment'; $string['author'] = 'author'; $string['authorview'] = 'Browse by Author'; $string['back'] = 'Back'; -$string['cantexportentry'] = 'Could not export the entry to the main glossary'; $string['cantinsertcat'] = 'Can\'t insert category'; $string['cantinsertrec'] = 'Can\'t insert record'; $string['cantinsertrel'] = 'Can\'t insert relation category-entry'; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index c729ddec61..6b7a70d197 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -498,9 +498,7 @@ class assignment_base { $assignment->id = $assignment->instance; $assignment->courseid = $assignment->course; - if (!$DB->update_record('assignment', $assignment)) { - return false; - } + $DB->update_record('assignment', $assignment); if ($assignment->timedue) { $event = new object(); @@ -658,14 +656,10 @@ class assignment_base { if (!isset($submission->submissioncomment)) { $submission->submissioncomment = ''; } - if (!$sid = $DB->insert_record('assignment_submissions', $submission)) { - return false; - } + $sid = $DB->insert_record('assignment_submissions', $submission); $submission->id = $sid; } else { - if (!$DB->update_record('assignment_submissions', $submission)) { - return false; - } + $DB->update_record('assignment_submissions', $submission); } // triger grade event diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php index b0685d9537..58c1a8e42d 100644 --- a/mod/assignment/type/online/assignment.class.php +++ b/mod/assignment/type/online/assignment.class.php @@ -173,9 +173,7 @@ class assignment_online extends assignment_base { $update->data2 = $data->format; $update->timemodified = time(); - if (!$DB->update_record('assignment_submissions', $update)) { - return false; - } + $DB->update_record('assignment_submissions', $update); $submission = $this->get_submission($USER->id); $this->update_grade($submission); diff --git a/mod/data/field.php b/mod/data/field.php index 3f64edf8f7..c6d67941e3 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -168,9 +168,7 @@ $rec->id = $data->id; $rec->defaultsort = 0; $rec->defaultsortdir = 0; - if (!$DB->update_record('data', $rec)) { - print_error('updatingerror', 'data'); - } + $DB->update_record('data', $rec); } add_to_log($course->id, 'data', 'fields delete', @@ -203,11 +201,8 @@ $rec->defaultsort = $defaultsort; $rec->defaultsortdir = $defaultsortdir; - if ($DB->update_record('data', $rec)) { - redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2); - } else { - print_error('updatingerror', 'data'); - } + $DB->update_record('data', $rec); + redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2); exit; } break; diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 962230f5b8..6d9b3ac649 100755 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -140,10 +140,7 @@ class data_field_picture extends data_field_base { // Get the old field data so that we can check whether the thumbnail dimensions have changed $oldfield = $DB->get_record('data_fields', array('id'=>$this->field->id)); - if (!$DB->update_record('data_fields', $this->field)) { - notify('updating of new field failed!'); - return false; - } + $DB->update_record('data_fields', $this->field); // Have the thumbnail dimensions changed? if ($oldfield && ($oldfield->param4 != $this->field->param4 || $oldfield->param5 != $this->field->param5)) { diff --git a/mod/data/lib.php b/mod/data/lib.php index c427dba8b1..47085a817f 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -201,10 +201,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/ function update_field() { global $DB; - if (!$DB->update_record('data_fields', $this->field)) { - notify('updating of new field failed!'); - return false; - } + $DB->update_record('data_fields', $this->field); return true; } @@ -550,11 +547,8 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa $newdata = new object(); $newdata->id = $data->id; $newdata->{$template} = $str; - if (!$DB->update_record('data', $newdata)) { - notify('Error updating template'); - } else { - $data->{$template} = $str; - } + $DB->update_record('data', $newdata); + $data->{$template} = $str; } return $str; diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 7013e093ef..776e189b01 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -132,9 +132,7 @@ function feedback_update_instance($feedback) { } //save the feedback into the db - if (!$DB->update_record("feedback", $feedback)) { - return false; - } + $DB->update_record("feedback", $feedback); //create or update the new events feedback_set_events($feedback); diff --git a/mod/forum/lib.php b/mod/forum/lib.php index b0de7c6d30..ae707a68a3 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4519,9 +4519,7 @@ function forum_update_post($post, $mform, &$message) { $post->modified = time(); - if (!$DB->update_record('forum_posts', $post)) { - return false; - } + $DB->update_record('forum_posts', $post); $discussion->timemodified = $post->modified; // last modified tracking $discussion->usermodified = $post->userid; // last modified tracking @@ -4534,9 +4532,7 @@ function forum_update_post($post, $mform, &$message) { $post->message = file_save_draft_area_files($post->itemid, $context->id, 'forum_post', $post->id, array('subdirs'=>true), $post->message); $DB->set_field('forum_posts', 'message', $post->message, array('id'=>$post->id)); - if (!$DB->update_record('forum_discussions', $discussion)) { - return false; - } + $DB->update_record('forum_discussions', $discussion); forum_add_attachment($post, $forum, $cm, $mform, $message); @@ -7684,9 +7680,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), // Change the forum type to general. $forum->type = 'general'; - if (!$DB->update_record('forum', $forum)) { - print_error('cannotconvertteachertogeneral', 'forum'); - } + $DB->update_record('forum', $forum); $context = get_context_instance(CONTEXT_MODULE, $cmid); diff --git a/mod/forum/post.php b/mod/forum/post.php index 6118a3fcea..e58c900a43 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -576,9 +576,7 @@ if (($forum->type == 'single') && ($updatepost->parent == '0')){ // updating first post of single discussion type -> updating forum intro $forum->intro = $updatepost->message; $forum->timemodified = time(); - if (!$DB->update_record("forum", $forum)) { - print_error("couldnotupdate", "forum", $errordestination); - } + $DB->update_record("forum", $forum); } $timemessage = 2; diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 2302d10c2a..23cb0aec15 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -89,9 +89,7 @@ $entry->glossaryid = $mainglossary->id; $entry->sourceglossaryid = $glossary->id; - if (!$DB->update_record('glossary_entries', $entry)) { - print_error('cantexportentry', 'glossary'); - } + $DB->update_record('glossary_entries', $entry); // move attachments too $fs = get_file_storage(); diff --git a/mod/glossary/import.php b/mod/glossary/import.php index cf370af47a..e47d60bf4c 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -271,24 +271,15 @@ $category = new object(); $category->name = $newcat->name; $category->glossaryid = $glossary->id; - if ( !$category->id = $DB->insert_record("glossary_categories",$category)) { - // add to exception report (can't insert category) - $rejections .= " " . get_string("category","glossary") . ":$newcat->name" . - "" . get_string("cantinsertcat","glossary"). ""; - } else { - $importedcats++; - } + $category->id = $DB->insert_record("glossary_categories",$category); + $importedcats++; } if ( $category ) { // inserting the new relation $entrycat = new opbject(); $entrycat->entryid = $newentry->id; $entrycat->categoryid = $category->id; - if ( !$DB->insert_record("glossary_entries_categories",$entrycat) ) { - // add to exception report (can't insert relation) - $rejections .= " " . get_string("category","glossary") . ":$newcat->name" . - "" . get_string("cantinsertrel","glossary"). ""; - } + $DB->insert_record("glossary_entries_categories",$entrycat); } } }