Skip to content

Fix "Event not exist" error when editing a meeting link after saving in Tiny editor#3234

Open
weilai-irl wants to merge 1 commit into
wip-130956-m502from
wip-131273-m502
Open

Fix "Event not exist" error when editing a meeting link after saving in Tiny editor#3234
weilai-irl wants to merge 1 commit into
wip-130956-m502from
wip-131273-m502

Conversation

@weilai-irl

@weilai-irl weilai-irl commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 12, 2026 15:15
@weilai-irl weilai-irl changed the title Fix "Event not exist" error when editing a meeting link after saving… Fix "Event not exist" error when editing a meeting link after saving in Tiny editor Jun 12, 2026
@weilai-irl weilai-irl self-assigned this Jun 12, 2026
@weilai-irl weilai-irl added this to the 2026-03 milestone Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses failures when re-editing an existing Teams meeting link in the Tiny editor by making URL hashing stable even if Moodle rewrites percent-encoded sequences to uppercase during HTML re-save.

Changes:

  • Normalises %xx percent-encoding to uppercase before hashing meeting URLs (with backward-compatible fallback to previous lowercase-hash rows).
  • Adds an upgrade step intended to recompute stored link / linkhash values using the normalised URL form.
  • Bumps the plugin version to trigger the upgrade.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
lib/editor/tiny/plugins/teamsmeeting/version.php Updates plugin version to deliver the fix (currently uses a non-integer version literal).
lib/editor/tiny/plugins/teamsmeeting/result.php Normalises incoming meeting URLs and adds fallback lookup for legacy hashes when viewing existing meetings.
lib/editor/tiny/plugins/teamsmeeting/db/upgrade.php Recomputes persisted URL/hash values to align old rows with the new normalisation scheme.
lib/editor/tiny/plugins/teamsmeeting/classes/external/get_meeting_details.php Normalises URL hashing for webservice lookups and adds legacy fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

$plugin->version = 2026042000;
$plugin->version = 2026042000.01;
upgrade_plugin_savepoint(true, 2025100207, 'tiny', 'teamsmeeting');
}

if ($oldversion < 2026042000.01) {
}
unset($records);

upgrade_plugin_savepoint(true, 2026042000.01, 'tiny', 'teamsmeeting');
Comment on lines +128 to +134
$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);
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)]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants