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

Accessibility errors report throws errors after destructive course restore

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.11.6, 4.1.14, 4.3.8, 4.4.4, 4.5
    • Accessibility toolkit
    • None
    • MOODLE_311_STABLE, MOODLE_401_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
    • MDL-74357-401_toolbrickfield_courserestore
    • MDL-74357-404_toolbrickfield_courserestore
    • MDL-74357-405_toolbrickfield_courserestore
    • MDL-74357-main_toolbrickfield_courserestore
    • Hide

      Setup:

      To test this, the site needs to be registered with Brickfield. If you don't have a Brickfield account, you can register here . (Make sure your server can be accessed over the internet, e.g. using ngrok)

      1. Activate your site with Brickfield in "Site administration / Plugins / Admin tools / Accessibility / Brickfield registration" by entering the API and Secret keys.
      2. Enable analysis requests in "Site administration / Plugins / Admin tools / Accessibility / Accessibility toolkit settings"

      Your site will also need cron to run in some matter, as the accessibility toolkit analysis needs cron to fully function.

      You will also need admin level access to the site, and set Debug messages to "Developer", at Site Administration > Development > Debugging.

      Also, please initially test using the MOODLE_XXX_STABLE branch, so that you will see the warning debug messages, which will then be prevented in the next run with the relevant patch code, when the same steps are followed.

      Test:

      1. Create a new course
      2. Turn editing mode on
      3. Create a label resource (Text and media area)
      4. Edit the resource using the editor's "View source" feature to insert the following HTML and save.

        This is <b>some bold text</b>!
        <br>This is <i>some italic text</i>!<br></p>
        <p><a href="https://www.rte.ie/">Click here</a>&nbsp;again</p>
        

      5. Add the "Accessibility review" block to the course.
      6. Click on the "Submit to Analysis" button to request that the course be analyzed by the accessibility toolkit.
      7. Manually run the scheduled task on the terminal or wait for cron to run: php admin/cli/scheduled_task.php --execute="\\tool_brickfield
        task process_analysis_requests"
      8. Confirm that the scheduled task completed successfully.
      9. View the error list for the course at More > Accessibility toolkit.
      10. Confirm that the three errors are present (bold text, italic text and non-descriptive link).

      Next, we are going to restore a backup course, and delete the contents of this course.

      1. CLick on the More tab in the course nav bar, and select Course reuse.
      2. Select Restore in the dropdown at the top of the page.
      3. In the Import a backup file section:
      4. Click on Choose a file... and then click on Browse to upload the example course backup zip file in this issue.
      5. Click on Upload this file.
      6. Click on Restore.
      7. Check that the details are all correct in the Course details page and click on Continue.
      8. Scroll down to the "Restore into this course" section.
      9. Be sure to click on the radio option "Delete the contents of the course and then restore", as the deletion process is being tested with this new patch.
      10. Click on Continue.
      11. Click on Next on the next page.
      12. Click on Next on the next page (Course settings).
      13. Click on Perform restore on the next page (Restore settings).
      14. Wait for the restore to be completed.
      15. Manually run the scheduled task on the terminal or wait for cron to run: php admin/cli/scheduled_task.php --execute="\\tool_brickfield
        task process_analysis_requests"
      16. Confirm that the scheduled task completed successfully.
      17. View the error list for the course at More > Accessibility toolkit.
      18. There should be some debug warnings as follows:
      19. Warning: Undefined array key xxx in /admin/tool/brickfield/classes/local/tool/tool.php on line 300
      20. Warning: Attempt to read property "name" on null in /admin/tool/brickfield/classes/local/tool/tool.php on line 301
      1. Use the patch for this issue, and repeat the steps for "restore a backup course" completely again.

      When this course restore and deletion is performed without the patch, the error list for the course at More > Accessibility toolkit will not show any errors, as all of the old deleted module data will have been removed.

      Show
      Setup: To test this, the site needs to be registered with Brickfield. If you don't have a Brickfield account, you can register here . (Make sure your server can be accessed over the internet, e.g. using ngrok) Activate your site with Brickfield in "Site administration / Plugins / Admin tools / Accessibility / Brickfield registration" by entering the API and Secret keys. Enable analysis requests in "Site administration / Plugins / Admin tools / Accessibility / Accessibility toolkit settings" Your site will also need cron to run in some matter, as the accessibility toolkit analysis needs cron to fully function. You will also need admin level access to the site, and set Debug messages to "Developer", at Site Administration > Development > Debugging. Also, please initially test using the MOODLE_XXX_STABLE branch, so that you will see the warning debug messages, which will then be prevented in the next run with the relevant patch code, when the same steps are followed. Test: Create a new course Turn editing mode on Create a label resource (Text and media area) Edit the resource using the editor's "View source" feature to insert the following HTML and save. This is <b>some bold text</b>! <br>This is <i>some italic text</i>!<br></p> <p><a href= "https://www.rte.ie/" >Click here</a>&nbsp;again</p> Add the "Accessibility review" block to the course. Click on the "Submit to Analysis" button to request that the course be analyzed by the accessibility toolkit. Manually run the scheduled task on the terminal or wait for cron to run: php admin/cli/scheduled_task.php --execute="\\tool_brickfield task process_analysis_requests" Confirm that the scheduled task completed successfully. View the error list for the course at More > Accessibility toolkit. Confirm that the three errors are present (bold text, italic text and non-descriptive link). Next, we are going to restore a backup course, and delete the contents of this course. CLick on the More tab in the course nav bar, and select Course reuse. Select Restore in the dropdown at the top of the page. In the Import a backup file section: Click on Choose a file... and then click on Browse to upload the example course backup zip file in this issue. Click on Upload this file. Click on Restore. Check that the details are all correct in the Course details page and click on Continue. Scroll down to the "Restore into this course" section. Be sure to click on the radio option "Delete the contents of the course and then restore", as the deletion process is being tested with this new patch. Click on Continue. Click on Next on the next page. Click on Next on the next page (Course settings). Click on Perform restore on the next page (Restore settings). Wait for the restore to be completed. Manually run the scheduled task on the terminal or wait for cron to run: php admin/cli/scheduled_task.php --execute="\\tool_brickfield task process_analysis_requests" Confirm that the scheduled task completed successfully. View the error list for the course at More > Accessibility toolkit. There should be some debug warnings as follows: Warning: Undefined array key xxx in /admin/tool/brickfield/classes/local/tool/tool.php on line 300 Warning: Attempt to read property "name" on null in /admin/tool/brickfield/classes/local/tool/tool.php on line 301 Use the patch for this issue, and repeat the steps for "restore a backup course" completely again. When this course restore and deletion is performed without the patch, the error list for the course at More > Accessibility toolkit will not show any errors, as all of the old deleted module data will have been removed.
    • Hide

      Code verified against automated checks.

      Checked MDL-74357 using repository: https://github.com/brickfield/moodle/

      More information about this report

      Built on: Mon 21 Oct 2024 08:50:18 PM UTC

      Show
      Code verified against automated checks. Checked MDL-74357 using repository: https://github.com/brickfield/moodle/ MOODLE_401_STABLE (0 errors / 0 warnings) [branch: MDL-74357-401_toolbrickfield_courserestore | CI Job ] MOODLE_404_STABLE (0 errors / 0 warnings) [branch: MDL-74357-404_toolbrickfield_courserestore | CI Job ] MOODLE_405_STABLE (0 errors / 0 warnings) [branch: MDL-74357-405_toolbrickfield_courserestore | CI Job ] main (0 errors / 0 warnings) [branch: MDL-74357-main_toolbrickfield_courserestore | CI Job ] More information about this report Built on: Mon 21 Oct 2024 08:50:18 PM UTC
    • Hide

      Launching automatic jobs for branch MDL-74357-401_toolbrickfield_courserestore

      Launching automatic jobs for branch MDL-74357-404_toolbrickfield_courserestore

      Launching automatic jobs for branch MDL-74357-405_toolbrickfield_courserestore

      Launching automatic jobs for branch MDL-74357-main_toolbrickfield_courserestore

      Built on: Tue Oct 29 06:30:23 AM UTC 2024

      Show
      Launching automatic jobs for branch MDL-74357 -401_toolbrickfield_courserestore https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17155/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58388/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58389/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-74357 -404_toolbrickfield_courserestore https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17156/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58390/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58391/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-74357 -405_toolbrickfield_courserestore https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17157/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58392/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58393/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-74357 -main_toolbrickfield_courserestore https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17158/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58394/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58395/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58396/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/58397/ App tests (stable app version) Built on: Tue Oct 29 06:30:23 AM UTC 2024

      After overwriting an existing course with content with a backup file with different content, and selecting "Delete the contents of this course and then restore", the errors tab of the Brickfield accessibility report throws errors:

      Notice: Undefined offset: 494128 in /var/www/html/admin/tool/brickfield/classes/local/tool/tool.php on line 300
      Call Stack

      1.    Time    Memory    Function    Location
        1    0.0001    365048    {main}( )    .../index.php:0
        2    0.3149    7066584    tool_brickfield\local\tool\errors->get_output( )    .../index.php:146
        3    0.3155    7068784    tool_brickfield\output\errors\renderer->display( )    .../tool.php:210
        4    0.3161    7074336    tool_brickfield\local\tool\tool::get_instance_name( )    .../renderer.php:76

      ( ! ) Notice: Trying to get property 'name' of non-object in /var/www/html/admin/tool/brickfield/classes/local/tool/tool.php on line 301
      Call Stack

      1.    Time    Memory    Function    Location
        1    0.0001    365048    {main}( )    .../index.php:0
        2    0.3149    7066584    tool_brickfield\local\tool\errors->get_output( )    .../index.php:146
        3    0.3155    7068784    tool_brickfield\output\errors\renderer->display( )    .../tool.php:210
        4    0.3161    7074336    tool_brickfield\local\tool\tool::get_instance_name( )    .../renderer.php:76

      It appears the error comes from the module no longer being in the course_modules table (since it was deleted during the destructive restore).

      I believe the course_restore event handler puts notations in the process table so when the cron task tool_brickfield\task\bulk_process_courses is run, it picks up these changes are modifies the areas table to remove deleted modules and add new or updated modules to be checked. However on that cron task, we are seeing the following error:

      Notice: Undefined offset: 0 in /var/www/html/admin/tool/brickfield/classes/manager.php on line 386

      Call Stack:
          0.0008     346904   1. {main}() /var/www/html/admin/cli/scheduled_task.php:0
          0.4780    2909424   2. cron_run_inner_scheduled_task() /var/www/html/admin/cli/scheduled_task.php:167
          0.4989    3629936   3. tool_brickfield\task\bulk_process_courses->execute() /var/www/html/lib/cronlib.php:253
          0.5002    3630032   4. tool_brickfield\accessibility::bulk_process_courses_cron() /var/www/html/admin/tool/brickfield/classes/task/bulk_process_courses.php:46
          0.5026    3631824   5. tool_brickfield\accessibility::bulk_processing() /var/www/html/admin/tool/brickfield/classes/accessibility.php:158
          0.5026    3631824   6. tool_brickfield\manager::check_course_updates() /var/www/html/admin/tool/brickfield/classes/accessibility.php:173
          0.5039    3642024   7. tool_brickfield\manager::find_new_or_updated_areas_per_course() /var/www/html/admin/tool/brickfield/classes/manager.php:513
          1.2584    4011320   8. tool_brickfield\manager::check_scheduled_areas() /var/www/html/admin/tool/brickfield/classes/manager.php:347

      I have tried to debug further but cannot determine why the areas table is not properly being updated after the destructive course restore. Any help would be most appreciated!

            bigmoodle Max Larkin
            meltonml Michelle Melton
            Karen Holland Karen Holland
            Safat Shahin Safat Shahin
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 15 minutes
                15m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.