Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-66769

Create a task to clean up unused H5P content

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a label in a course
      2. Upload an H5P file using the Atto button
      3. Save the label
      4. Access to the course to view the H5P content inside the label.
      5. Remove the label.
      6. Run cron

        php admin cli/cron.php
        

      7. Ensure you can find H5PID of activity to be deleted by running

        SELECT h5p.id, h5p.pathnamehash FROM mdl_h5p h5p LEFT JOIN mdl_files f on f.pathnamehash = h5p.pathnamehash WHERE f.pathnamehash is null;

      8. Ensure you can find files that will be deleted by running (compose comma separated list COMMASEPARATEDIDLIST from result like 3,5,56 etc)

        SELECT id from mdl_files WHERE itemid = H5PID and filearea = 'content' AND component = 'core_h5p';
        

      9. Run cleanup cron task

        php admin/cli/scheduled_task.php --execute='\core\task\h5p_clean_orphaned_records_task'
        

      10. Ensure this sql returns no records:

        SELECT h5p.id, h5p.pathnamehash FROM mdl_h5p h5p LEFT JOIN mdl_files f on f.pathnamehash = h5p.pathnamehash WHERE f.pathnamehash is null;

      11. Ensure that files are actually deleted so the following query return empty set

        SELECT * FROM mdl_files WHERE id IN [COMMASEPARATEDIDLIST];
        

      12. Go to course recycle bin (click cog on course page, then Recycle bin)
      13. Restore your label
      14. Ensure restored label has h5p content
      15. Delete the course
      16. Run cron

        php admin cli/cron.php
        

      17. Run cleanup cron task

        php admin/cli/scheduled_task.php --execute='\core\task\h5p_clean_orphaned_records_task'
        

      18. Restore the course from recycle bin (in category administration)
      19. Ensure label is still available and shows h5p content

       
       

      Show
      Create a label in a course Upload an H5P file using the Atto button Save the label Access to the course to view the H5P content inside the label. Remove the label. Run cron php admin cli/cron.php Ensure you can find H5PID of activity to be deleted by running SELECT h5p.id, h5p.pathnamehash FROM mdl_h5p h5p LEFT JOIN mdl_files f on f.pathnamehash = h5p.pathnamehash WHERE f.pathnamehash is null ; Ensure you can find files that will be deleted by running (compose comma separated list COMMASEPARATEDIDLIST from result like 3,5,56 etc) SELECT id from mdl_files WHERE itemid = H5PID and filearea = 'content' AND component = 'core_h5p' ; Run cleanup cron task php admin/cli/scheduled_task.php --execute= '\core\task\h5p_clean_orphaned_records_task' Ensure this sql returns no records: SELECT h5p.id, h5p.pathnamehash FROM mdl_h5p h5p LEFT JOIN mdl_files f on f.pathnamehash = h5p.pathnamehash WHERE f.pathnamehash is null ; Ensure that files are actually deleted so the following query return empty set SELECT * FROM mdl_files WHERE id IN [COMMASEPARATEDIDLIST]; Go to course recycle bin (click cog on course page, then Recycle bin) Restore your label Ensure restored label has h5p content Delete the course Run cron php admin cli/cron.php Run cleanup cron task php admin/cli/scheduled_task.php --execute= '\core\task\h5p_clean_orphaned_records_task' Restore the course from recycle bin (in category administration) Ensure label is still available and shows h5p content    
    • Affected Branches:
      MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull 3.11 Branch:
      MDL-66769-311
    • Pull Master Branch:
      MDL-66769-master
    • Sprint:
      Moppies Kanban, H5P Sprint 3, H5P Sprint Relase 3.8

      Description

      We need some clean up task to remove unused/removed H5P content.

      Possible scenario:

      1. Create a label in a course
      2. Upload an H5P file using the Atto button
      3. Save the label
      4. Access to the course to view the H5P content inside the label.
      5. Remove the label.

       
       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ilyatregubov Ilya Tregubov
              Reporter:
              sarjona Sara Arjona (@sarjona)
              Peer reviewer:
              Carlos Escobedo
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/May/21

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days, 50 minutes
                  3d 50m