MDL-63658 core_favourites: fix errors discovered on oracle db

- Assuming 1 would be a record that didn't exist. should be using 0.
- Missing space before AND in sql in provider.
This commit is contained in:
Jake Dallimore
2018-10-18 17:11:07 +08:00
parent 68eaa3150e
commit 21b50ebe19
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l
WHERE userid = :userid
AND component = :component";
if (!is_null($itemtype)) {
$sql .= "AND itemtype = :itemtype";
$sql .= " AND itemtype = :itemtype";
}
$params = ['userid' => $userid, 'component' => $component, 'itemtype' => $itemtype];
$contextlist->add_from_sql($sql, $params);
+2 -2
View File
@@ -201,7 +201,7 @@ class favourite_repository_testcase extends advanced_testcase {
// Try to get a favourite we know doesn't exist.
// We expect an exception in this case.
$this->expectException(dml_exception::class);
$favouritesrepo->find(1);
$favouritesrepo->find(0);
}
/**
@@ -414,7 +414,7 @@ class favourite_repository_testcase extends advanced_testcase {
$this->assertTrue($favouritesrepo->exists($createdfavourite->id));
// Verify exists returns false for non-existent favourite.
$this->assertFalse($favouritesrepo->exists(1));
$this->assertFalse($favouritesrepo->exists(0));
}
/**