Skip to content

Commit

Permalink
MDL-44667 database: fix incorrect usages of $DB->get_field
Browse files Browse the repository at this point in the history
Some places were passing 5 params, meaning the strictness param was
lost. This fixes those usages.
  • Loading branch information
snake committed Dec 4, 2017
1 parent 5f54a87 commit 3112c22
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions enrol/imsenterprise/tests/imsenterprise_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function test_user_delete() {
$this->set_xml_file(array($imsuser));

$this->imsplugin->cron();
$this->assertEquals(1, $DB->get_field('user', 'deleted', array('id' => $user->id), '*', MUST_EXIST));
$this->assertEquals(1, $DB->get_field('user', 'deleted', array('id' => $user->id), MUST_EXIST));
}

/**
Expand All @@ -227,7 +227,7 @@ public function test_user_delete_disabled() {
$this->set_xml_file(array($imsuser));

$this->imsplugin->cron();
$this->assertEquals(0, $DB->get_field('user', 'deleted', array('id' => $user->id), '*', MUST_EXIST));
$this->assertEquals(0, $DB->get_field('user', 'deleted', array('id' => $user->id), MUST_EXIST));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/submission/file/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function save(stdClass $submission, stdClass $data) {
$groupid = 0;
// Get the group name as other fields are not transcribed in the logs and this information is important.
if (empty($submission->userid) && !empty($submission->groupid)) {
$groupname = $DB->get_field('groups', 'name', array('id' => $submission->groupid), '*', MUST_EXIST);
$groupname = $DB->get_field('groups', 'name', array('id' => $submission->groupid), MUST_EXIST);
$groupid = $submission->groupid;
} else {
$params['relateduserid'] = $submission->userid;
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/submission/onlinetext/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function save(stdClass $submission, stdClass $data) {
$groupid = 0;
// Get the group name as other fields are not transcribed in the logs and this information is important.
if (empty($submission->userid) && !empty($submission->groupid)) {
$groupname = $DB->get_field('groups', 'name', array('id' => $submission->groupid), '*', MUST_EXIST);
$groupname = $DB->get_field('groups', 'name', array('id' => $submission->groupid), MUST_EXIST);
$groupid = $submission->groupid;
} else {
$params['relateduserid'] = $submission->userid;
Expand Down
2 changes: 1 addition & 1 deletion question/type/multianswer/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function get_question_options($question) {

// Get relevant data indexed by positionkey from the multianswers table.
$sequence = $DB->get_field('question_multianswer', 'sequence',
array('question' => $question->id), '*', MUST_EXIST);
array('question' => $question->id), MUST_EXIST);

$wrappedquestions = $DB->get_records_list('question', 'id',
explode(',', $sequence), 'id ASC');
Expand Down
2 changes: 1 addition & 1 deletion search/tests/behat/behat_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function global_search_expects_the_query_and_will_return($query, TableNod

// Find the specified activity.
$idnumber = $input['idnumber'];
$cmid = $DB->get_field('course_modules', 'id', ['idnumber' => $idnumber], '*', IGNORE_MISSING);
$cmid = $DB->get_field('course_modules', 'id', ['idnumber' => $idnumber], IGNORE_MISSING);
if (!$cmid) {
throw new Exception('Cannot find activity with idnumber: ' . $idnumber);
}
Expand Down

0 comments on commit 3112c22

Please sign in to comment.