Skip to content

Course reset: the unenrolled-users branch deletes the wrong podcast's files #15

Description

@nihaalshaikh

Summary

In pcast_reset_userdata(), the "episodes by users not enrolled" branch builds $unenrolledepisodessql that returns pcast_episodes.id, then calls get_coursemodule_from_instance('pcast', $pcastid) treating each episode id as a podcast instance id and delete_area_files(..., 'episode') on the result.

Impact

Files and ratings are deleted from whichever podcast instance happens to share an id with an episode - potentially wiping all media of an unrelated podcast in the same course.

Location

lib.php:1143-1151

Note

The reset_pcast_all path itself is fine - it does not throw on extra query params (fix_sql_params only errors on too few). Verified live: reset_pcast_all ran clean, episodes before = 2, after = 0.

Suggested fix

Use the podcast-instance subquery ($allpcastssql) as the reset_pcast_all branch does, not the episode-id subquery.


Verified on a live install: Moodle 5.1.3, PHP 8.2, MariaDB, plugin version 2025121201 (current master). Reproduced 2026-09-02.


Found during the mod_pcast review/test pass (ClickUp 86cb46r9t). Line numbers are against master @ 73bb255.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghighHigh: bug or significant quality issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions