fix(set_ode): refresh entry file metadata on the new revision after online package replacement#44
Merged
eXeLearningProject merged 2 commits intomainfrom Apr 30, 2026
Conversation
set_ode.php was calling exeweb_package::get_mainfile() without the $itemid argument, so the lookup defaulted to itemid 0 while expand_package extracted into the new $exeweb->revision. The entry file was therefore never re-detected, leaving entrypath/entryname stale across online saves. Pass the package itemid to get_mainfile, persist the new revision and entry file together, and defer the cleanup of older package files until after a successful save so the activity stays usable if anything fails.
2 tasks
Collaborator
Author
|
Follow-up: the actual root cause (broken images served by Moodle when content comes from the Finish to Moodle path) lives on the eXeLearning side and is fixed in:
The client now flushes pending assets to the server before triggering This Moodle-side PR (#44) keeps the entry-file metadata and package filearea in sync after each online save, complementing that fix. |
eXeLearningProject
approved these changes
Apr 30, 2026
ignaciogros
approved these changes
Apr 30, 2026
Collaborator
ignaciogros
left a comment
There was a problem hiding this comment.
Same results in my tests:
I insert an image using the online version, but the image throws a 404 error in Moodle
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.
Summary
Complements exelearning/exelearning#1740 (which fixes the visible 404 on
content/resources/<uuid>.pngby generating the webzip in the browser). This PR fixes a separate Moodle-side consistency bug surfaced while investigating mod_exeweb#42: after the first online save,entrypath,entrynameand the entry filesortorderkept pointing at the previous revision.Root cause
set_ode.phpextracted the new package into$exeweb->revisionbut calledexeweb_package::get_mainfile()without an$itemid. The defaultitemid = 0always missed the freshly extracted files, so:entrypath/entrynamewere never refreshed after the first online save.file_set_sortorder()was a no-op for the entry file.The embedded editor flow (
editor/save.php) already passes the right itemid, which is why embedded mode works. The bug is specific to the online (set_ode.php) entry point.Changes
set_ode.php$package->get_itemid()toget_mainfile()so the entry file is detected on the new revision.entrypath/entryname/timemodified/usermodifiedin a singleupdate_record()call.tests/exeweb_package_test.php(new)expand_package()+get_mainfile()against a non-zero itemid (the actual case for every online save after the first).get_mainfile()without an itemid silently returns false (the regression behind this issue).expand_package()cleans up stale revisions.Relationship to mod_exeweb#42
The 404 on
content/resources/<uuid>.pngreported in #42 is fixed on the eXeLearning side by exelearning/exelearning#1740 — the webzip is now generated in the browser (where the live Y.Doc and IndexedDB asset blobs are), andBaseExporter.addAssetsToZipWithResourcePathalso writes each asset under its<assetId><ext>literal path so any stalecontent/resources/<uuid>.<ext>reference still resolves.This PR does not make that symptom go away on its own. It addresses a separate, real consistency bug in Moodle: keeping the activity's entry-file bookkeeping in sync after every online save so
entrypath/entryname/revisiondon't drift, and so the legacy server-side webzip fallback path doesn't keep stale references either.Refs: mod_exeweb#42, exelearning/exelearning#1740
Test plan
composer test(full PHPUnit suite under the bundled Moodle docker image).entrypath/entrynamereflect the new package and the entry file is served correctly.Moodle Playground Preview
The changes in this pull request can be previewed and tested using a Moodle Playground instance.