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

Missing return type check in block_edit_form::process_dynamic_submission

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.4, 4.5
    • Blocks

      The call to add_block_at_end_of_default_region can return null, but if it does, an exception is thrown (block_not_on_page_exception) when find_instance is called.

       

      This can happen if a plugin overrides add_block_at_end_of_default_region and intentionally returns null in order to prevent a user adding a block:

      https://moodle.org/plugins/tool_blocksmanager

      https://github.com/moodle/moodle/blob/main/blocks/edit_form.php#L434-L452

      Steps to reproduce:

      1. Setup a Moodle site
      2. Install the tool_blocksmanager plugin
        • Open the site root directory in your terminal
        • git clone -b MOODLE_404_STABLE git@github.com:catalyst/moodle_tool_blocksmanager.git admin/tool/blocksmanager
      3. Navigate to /admin/tool/blocksmanager/region.php
      4. Click Add new locked region
        • Set region to side-pre
        • Select all categories (e.g. Category 1)
        • Set Allow to add? to No
        • Save changes
      5. Navigate to a course in one of the selected categories
      6. Log in as a teacher (setting role to teacher won't work)
      7. Attempt to add a block (e.g. Text block)
      8. Verify you see an exception message
      9. Apply the MDL-83044 patch
      10. Attempt to add a block
      11. Verify you see a red notice banner instead

        1. issue_record.webm
          5.56 MB
        2. issue.png
          issue.png
          112 kB
        3. Screencast from 29-10-24.webm
          5.27 MB
        4. Screenshot from 2024-09-08 21-27-00.png
          Screenshot from 2024-09-08 21-27-00.png
          139 kB

            avdb Alexander Van der Bellen
            avdb Alexander Van der Bellen
            Dmitrii Metelkin Dmitrii Metelkin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

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

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