Skip to content

Commit

Permalink
MDL-18293 removed obsoleted checking of return values from insert and…
Browse files Browse the repository at this point in the history
… update_record + unused strings cleanup
  • Loading branch information
skodak committed Jun 13, 2009
1 parent a8f3a65 commit fc29e51
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 86 deletions.
4 changes: 1 addition & 3 deletions backup/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ function backup_putid($backup_unique_code, $table, $old_id, $new_id, $info="") {
$rec->new_id = ($new_id === null? 0 : $new_id);
$rec->info = $info_to_save;

if (!$DB->insert_record('backup_ids', $rec, false)) {
$status = false;
}
$DB->insert_record('backup_ids', $rec, false);
}
return $status;
}
Expand Down
25 changes: 5 additions & 20 deletions backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1265,13 +1265,7 @@ function restore_create_sections(&$restore, $xml_file) {
}

// Add record
if(!$DB->insert_record('course_modules_completion',$data)) {
if (!defined('RESTORE_SILENTLY')) {
echo "<p>Failed to insert completion data record.</p>";
}
$status=false;
continue;
}
$DB->insert_record('course_modules_completion',$data);
}
}

Expand Down Expand Up @@ -1306,13 +1300,7 @@ function restore_create_sections(&$restore, $xml_file) {
// Grade id is not converted (convert later)

// Add record
if(!$DB->insert_record('course_modules_availability',$data)) {
if (!defined('RESTORE_SILENTLY')) {
echo "<p>Failed to insert availability data record.</p>";
}
$status=false;
continue;
}
$DB->insert_record('course_modules_availability',$data);
}
}
} else {
Expand Down Expand Up @@ -3565,9 +3553,8 @@ function restore_create_groups_members($group_id,$info,$restore) {
//The structure is equal to the db, so insert the groups_members
if ($DB->record_exists("groups_members", array('groupid'=>$group_member->groupid, 'userid'=>$group_member->userid))) {
// user already member
} else if (!$DB->insert_record ("groups_members", $group_member)) {
$status = false;
continue;
} else {
$DB->insert_record ("groups_members", $group_member);
}

//Do some output
Expand Down Expand Up @@ -3689,9 +3676,7 @@ function restore_create_groupings_groups($restore,$xml_file) {
$gro_member->groupid = $group->new_id;
$gro_member->groupingid = $grouping->new_id;
if (!$DB->get_record('groupings_groups', array('groupid'=>$gro_member->groupid, 'groupingid'=>$gro_member->groupingid))) {
if (!$DB->insert_record('groupings_groups', $gro_member)) {
$status = false;
}
$DB->insert_record('groupings_groups', $gro_member);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,7 @@ function course_set_display($courseid, $display=0) {
$record->userid = $USER->id;
$record->course = $courseid;
$record->display = $display;
if (!$DB->insert_record("course_display", $record)) {
notify("Could not save your course display!");
}
$DB->insert_record("course_display", $record);
}

return $USER->display[$courseid] = $display; // Note: = not ==
Expand Down
4 changes: 1 addition & 3 deletions enrol/paypal/ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@

// ALL CLEAR !

if (!$DB->insert_record("enrol_paypal", $data)) { // Insert a transaction record
message_paypal_error_to_admin("Error while trying to insert valid transaction", $data);
}
$DB->insert_record("enrol_paypal", $data);

if (!enrol_into_course($course, $user, 'paypal')) {
message_paypal_error_to_admin("Error while trying to enrol ".fullname($user)." in '$course->fullname'", $data);
Expand Down
8 changes: 1 addition & 7 deletions grade/import/csv/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,7 @@
$newgrade->importcode = $importcode;
$newgrade->userid = $studentid;
$newgrade->importer = $USER->id;
if (!$DB->insert_record('grade_import_values', $newgrade)) {
// could not insert into temporary table
$status = false;
import_cleanup($importcode);
notify(get_string('importfailed', 'grades'));
break 2;
}
$DB->insert_record('grade_import_values', $newgrade);
}
}

Expand Down
7 changes: 1 addition & 6 deletions grade/import/xml/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ function import_xml_grades($text, $course, &$error) {
}

// insert this grade into a temp table
if (!$DB->insert_record('grade_import_values', $newgrade)) {
$status = false;
// could not insert into temp table
$error = get_string('importfailed', 'grades');
break;
}
$DB->insert_record('grade_import_values', $newgrade);
}

} else {
Expand Down
4 changes: 1 addition & 3 deletions lib/questionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,7 @@ function save_question_session($question, $state) {
$session->sumpenalty = $state->sumpenalty;
$session->manualcomment = $state->manualcomment;
$session->flagged = !empty($state->newflaggedstate);
if (!$DB->insert_record('question_sessions', $session)) {
return false;
}
$DB->insert_record('question_sessions', $session);
} else {
$session->newest = $state->id;
if (question_state_is_graded($state) or $state->event == QUESTION_EVENTOPEN) {
Expand Down
4 changes: 1 addition & 3 deletions message/output/email/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function xmldb_message_email_install() {

$provider = new object();
$provider->name = 'email';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}
4 changes: 1 addition & 3 deletions message/output/email/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ function email_install(){

$provider = new object();
$provider->name = 'email';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}
4 changes: 1 addition & 3 deletions message/output/jabber/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function xmldb_message_jabber_install(){

$provider = new object();
$provider->name = 'jabber';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}
4 changes: 1 addition & 3 deletions message/output/jabber/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ function jabber_install(){

$provider = new object();
$provider->name = 'jabber';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}
4 changes: 1 addition & 3 deletions message/output/popup/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ function xmldb_message_popup_install() {

$provider = new object();
$provider->name = 'popup';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}
4 changes: 1 addition & 3 deletions message/output/popup/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ function popup_install(){

$provider = new object();
$provider->name = 'popup';
if (!$DB->insert_record('message_processors', $provider)) {
$return = false;
}
$DB->insert_record('message_processors', $provider);
return $result;
}

4 changes: 1 addition & 3 deletions message/output/popup/message_output_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function send_message($message) {
$procmessage->unreadmessageid = $message->id;
$procmessage->processorid = $processor->id;

if ( !$DB->insert_record('message_working', $procmessage) ) {
return false;
}
$DB->insert_record('message_working', $procmessage);

//should only save this message for later delivery
return true;
Expand Down
5 changes: 1 addition & 4 deletions mod/feedback/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ function feedback_import_loaded_data(&$data, $feedbackid){
}
$newitem->required = intval($item['@']['REQUIRED']);
$newitem->position = $position;
if (!$DB->insert_record('feedback_item', $newitem)) {
$error->stat = false;
$error->msg[] = 'item ('.$newitem->name.') not imported';
}
$DB->insert_record('feedback_item', $newitem);
}
return $error;
}
Expand Down
4 changes: 2 additions & 2 deletions mod/feedback/mapcourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
$sql = "SELECT id, feedbackid
FROM {feedback_sitecourse_map}
WHERE feedbackid = ? AND courseid = ?";
if (!$DB->get_records_sql($sql, array($map->feedbackid, $map->courseid)) && !$DB->insert_record('feedback_sitecourse_map', $map)) {
print_error('cannotmapfeedback', 'feedback');
if (!$DB->get_records_sql($sql, array($map->feedbackid, $map->courseid))) {
$DB->insert_record('feedback_sitecourse_map', $map);
}
}

Expand Down
4 changes: 1 addition & 3 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,7 @@ function forum_cron() {
$queue->discussionid = $discussion->id;
$queue->postid = $post->id;
$queue->timemodified = $post->created;
if (!$DB->insert_record('forum_queue', $queue)) {
mtrace("Error: mod/forum/cron.php: Could not queue for digest mail for id $post->id to user $userto->id ($userto->email) .. not trying again.");
}
$DB->insert_record('forum_queue', $queue);
continue;
}

Expand Down
4 changes: 1 addition & 3 deletions mod/lesson/action/continue.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,7 @@
$branch->flag = $branchflag;
$branch->timeseen = time();

if (!$DB->insert_record("lesson_branch", $branch)) {
print_error("Error: could not insert row into lesson_branch table");
}
$DB->insert_record("lesson_branch", $branch);

// this is called when jumping to random from a branch table
if($newpageid == LESSON_UNSEENBRANCHPAGE) {
Expand Down
4 changes: 1 addition & 3 deletions mod/quiz/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,7 @@ function quiz_after_add_or_update($quiz) {
$feedback->feedbacktext = $quiz->feedbacktext[$i];
$feedback->mingrade = $quiz->feedbackboundaries[$i];
$feedback->maxgrade = $quiz->feedbackboundaries[$i - 1];
if (!$DB->insert_record('quiz_feedback', $feedback, false)) {
return "Could not save quiz feedback.";
}
$DB->insert_record('quiz_feedback', $feedback, false);
}

// Update the events relating to this quiz.
Expand Down
6 changes: 1 addition & 5 deletions question/type/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -1688,11 +1688,7 @@ function restore($old_question_id,$new_question_id,$info,$restore) {
foreach ($extraquestionfields as $field) {
$record->$field = backup_todb($recordinfo['#'][strtoupper($field)]['0']['#']);
}
if (!$DB->insert_record($questionextensiontable, $record)) {
echo "Can't insert record in $questionextensiontable when restoring " .
$this->name() . ' question id ' . $question;
$status = false;
}
$DB->insert_record($questionextensiontable, $record);
}
//TODO restore extra data in answers
return $status;
Expand Down

0 comments on commit fc29e51

Please sign in to comment.