Closed leonstr closed 6 months ago
It looks like the cause is that element_deleted->create_from_element()
uses $DB->get_record('customcert_pages', ...)
using the obtained $page->templateid
to get the template record and so obtain the contextid to use for this event.
But template->delete_page()
calls $DB->delete_records('customcert_pages', ...)
before calling element_deleted->create_from_element()
so the required mdl_customcert_pages
row no longer exists.
PR #572 might do the trick.
Updated PR to include PHPUnit test that shows this error with the previous version but passes with the proposed fix.
Steps to reproduce issue:
Expected results:
Second page is deleted.
Actual results:
Problem seen with Moodle 4.1.2+ (Build: 20230406) with mod_customcert 2022112801 (7ee063e) and Moodle 4.2.1+ (Build: 20230714) and mod_customcert 2023042402 (9a11c53).