MDL-34161 fixes the external tool association to tool type on backup and restore. Prior to its fix, external tool were always associated to tool type 0 on restore as the backup did not contain the tool type information.
The fix however does not address the courses restored from backups made to that fix. Those courses have the external tools with a type of 0, which is somewhat mitigated as, on launch, moodle associates those external tool with a tool type dynamically on based on url matching. However, while appearing to be working properly, those links in the backup will still not contain tool type info.
This ticket proposes to re-use the heuristic around looking type by matching URL as happens on the actual launch of the course to assign the type (locallib#lti_get_tool_by_url_match).
Question is when should this happen:
- On backup: so that the backup contains the type id and type data needed to restore the course; this would allow the backup to embed information about the tool type so that it may be restored on other sites.
- On restore: so that older backups will be restored associated directly with a tool type if a matching tool pre-exists for that external tool url. This will allow pre-existing backup to restore properly given a match tool type exists, but will not be able to create missing course tool types as the information is not in the backup. Those would still be associated to 0. However, since current moodle logic already runs the match at runtime if the tool type is 0, it makes the need to fix on restore less acute.
This ticket will thus focus on including tool type info based on URL for tool type 0 for the backup case alone.