MDL-71801 mod_lti: set default keytype value when upgrading tool types

MDL-66920 added this field but didn't set defaults for upgrading tool
types. This patch fixes that for any 1.3 tools which don't yet have a
value for this field.
This commit is contained in:
Jake Dallimore
2022-03-29 14:10:23 +08:00
parent 25f22a3cb7
commit 962f75ec53
2 changed files with 26 additions and 1 deletions
+25
View File
@@ -186,5 +186,30 @@ function xmldb_lti_upgrade($oldversion) {
// Automatically generated Moodle v3.11.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2021051701) {
// This option 'Public key type' was added in MDL-66920, but no value was set for existing 1.3 tools.
// Set a default of 'RSA Key' for those LTI 1.3 tools without a value, representing the only key type they
// could use at the time of their creation. Existing tools which have since been resaved will not be impacted.
$sql = "SELECT t.id
FROM {lti_types} t
LEFT JOIN {lti_types_config} tc
ON (tc.typeid = t.id AND tc.name = :typename)
WHERE t.ltiversion = :ltiversion
AND tc.value IS NULL";
$params = ['typename' => 'keytype', 'ltiversion' => '1.3.0'];
$recordset = $DB->get_recordset_sql($sql, $params);
foreach ($recordset as $record) {
$DB->insert_record('lti_types_config', (object) [
'typeid' => $record->id,
'name' => 'keytype',
'value' => 'RSA_KEY'
]);
}
$recordset->close();
// Lti savepoint reached.
upgrade_mod_savepoint(true, 2021051701, 'lti');
}
return true;
}
+1 -1
View File
@@ -48,7 +48,7 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2021051700; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2021051701; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2021051100; // Requires this Moodle version.
$plugin->component = 'mod_lti'; // Full name of the plugin (used for diagnostics).
$plugin->cron = 0;