Skip to content

Commit

Permalink
Merge branch 'MDL-76170-master' of https://github.com/snake/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Nov 9, 2022
2 parents 5877ae3 + 3e17cf6 commit 613fe49
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions enrol/lti/classes/tool_provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ protected function onLaunch() {
if ($userlog->serviceurl != $serviceurl) {
$userlog->serviceurl = $serviceurl;
}
if (empty($userlog->consumersecret)) {
$userlog->consumersecret = $this->consumer->secret;
}
$userlog->lastaccess = time();
$DB->update_record('enrol_lti_users', $userlog);
} else {
Expand Down
21 changes: 21 additions & 0 deletions enrol/lti/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,26 @@ function xmldb_enrol_lti_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2022103100, 'enrol', 'lti');
}

if ($oldversion < 2022110300) {
// Update lti user information for any users missing a consumer secret.
// This applies to any user who has launched the tool (i.e. has lastaccess) but who doesn't have a secret recorded.
// This fixes a bug where enrol_lti_users records are created first during a member sync, and are missing the secret,
// even despite having launched the tool subsequently.
$sql = "SELECT lu.id, lc.secret
FROM {enrol_lti_users} lu
JOIN {enrol_lti_lti2_consumer} lc
ON (lu.consumerkey = lc.consumerkey256)
WHERE lu.consumersecret IS NULL
AND lu.lastaccess IS NOT NULL";
$affectedltiusersrs = $DB->get_recordset_sql($sql);
foreach ($affectedltiusersrs as $ltiuser) {
$DB->set_field('enrol_lti_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
}
$affectedltiusersrs->close();

// Lti savepoint reached.
upgrade_plugin_savepoint(true, 2022110300, 'enrol', 'lti');
}

return true;
}
2 changes: 1 addition & 1 deletion enrol/lti/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2022103100; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022110300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'enrol_lti'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = [
Expand Down

0 comments on commit 613fe49

Please sign in to comment.