mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
MDL-76362 enrol_lti: Prevent calling to DataConnector with null keys
While it could have been fixed in DataConnector (3rd part lib), better prevent in our code to call to it with null keys. Covered by unit tests.
This commit is contained in:
parent
e6dfa9ff3c
commit
03bc275093
@ -88,16 +88,18 @@ class data_connector extends DataConnector {
|
||||
global $DB;
|
||||
|
||||
$id = $consumer->getRecordId();
|
||||
$key = $consumer->getKey();
|
||||
$result = false;
|
||||
|
||||
if (!empty($id)) {
|
||||
$result = $DB->get_record($this->consumertable, ['id' => $id]);
|
||||
} else {
|
||||
$key256 = DataConnector::getConsumerKey($consumer->getKey());
|
||||
} else if (!empty($key)) {
|
||||
$key256 = DataConnector::getConsumerKey($key);
|
||||
$result = $DB->get_record($this->consumertable, ['consumerkey256' => $key256]);
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
if (empty($key256) || empty($result->consumerkey) || ($consumer->getKey() === $result->consumerkey)) {
|
||||
if (empty($key256) || empty($result->consumerkey) || ($key === $result->consumerkey)) {
|
||||
$this->build_tool_consumer_object($result, $consumer);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user