Fix "Event not exist" error when editing a meeting link after saving in Tiny editor#3232
Open
weilai-irl wants to merge 1 commit into
Open
Fix "Event not exist" error when editing a meeting link after saving in Tiny editor#3232weilai-irl wants to merge 1 commit into
weilai-irl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses failures when re-opening/editing an existing Teams meeting link in the Tiny editor after Moodle re-saves HTML and changes the casing of percent-encoded bytes (e.g. %2f → %2F), causing SHA1-based lookups to miss the stored record.
Changes:
- Normalise percent-encoding to uppercase before hashing meeting URLs, with a fallback lookup for legacy lowercase-hashed rows.
- Add an upgrade step intended to recompute stored
link/linkhashvalues based on the normalised URL. - Bump the plugin version/release.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/editor/tiny/plugins/teamsmeeting/version.php | Updates plugin version/release to ship the fix. |
| lib/editor/tiny/plugins/teamsmeeting/result.php | Normalises incoming meeting link percent-encoding and adds fallback lookup when viewing an existing meeting. |
| lib/editor/tiny/plugins/teamsmeeting/db/upgrade.php | Adds migration to normalise stored links and recompute linkhash. |
| lib/editor/tiny/plugins/teamsmeeting/classes/external/get_meeting_details.php | Normalises URL before hashing for DB lookup, with fallback for legacy rows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+28
to
+30
| $plugin->version = 2025100307.01; | ||
| $plugin->requires = 2025040800; | ||
| $plugin->release = '5.0.6'; | ||
| $plugin->release = '5.0.7'; |
Comment on lines
+124
to
+137
| if ($oldversion < 2025100307.01) { | ||
| // Recompute linkhash using percent-encoding-normalised URLs so that | ||
| // hashes are stable regardless of whether Moodle has uppercased %xx | ||
| // sequences when saving HTML content (RFC 3986 normalisation). | ||
| $records = $DB->get_records('tiny_teamsmeeting', null, 'id ASC', 'id, link'); | ||
| foreach ($records as $record) { | ||
| $normalised = preg_replace_callback('/%[0-9a-f]{2}/i', fn($m) => strtoupper($m[0]), $record->link); | ||
| $DB->set_field('tiny_teamsmeeting', 'linkhash', sha1($normalised), ['id' => $record->id]); | ||
| $DB->set_field('tiny_teamsmeeting', 'link', $normalised, ['id' => $record->id]); | ||
| } | ||
| unset($records); | ||
|
|
||
| upgrade_plugin_savepoint(true, 2025100307.01, 'tiny', 'teamsmeeting'); | ||
| } |
Comment on lines
+114
to
+125
| // Normalise percent-encoding to uppercase before hashing so lookups | ||
| // succeed whether or not Moodle re-saved the HTML (which uppercases %xx). | ||
| $normalised = preg_replace_callback('/%[0-9a-f]{2}/i', fn($m) => strtoupper($m[0]), $url); | ||
| $record = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($normalised)]); | ||
|
|
||
| if (!$record) { | ||
| // Fallback for rows created before normalisation: try lowercase hex digits. | ||
| $lowercased = preg_replace_callback('/%[0-9A-F]{2}/', fn($m) => strtolower($m[0]), $normalised); | ||
| if ($lowercased !== $normalised) { | ||
| $record = $DB->get_record('tiny_teamsmeeting', ['linkhash' => sha1($lowercased)]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.