Skip to content

Commit

Permalink
MDL-71801 mod_lti: set default keytype value when upgrading tool types
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
snake committed Mar 29, 2022
1 parent 25f22a3 commit 962f75e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions mod/lti/db/upgrade.php
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion mod/lti/version.php
Expand Up @@ -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;

0 comments on commit 962f75e

Please sign in to comment.