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

section_edit_control_menu invalid default for $attr

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.0
    • 3.0
    • Course
    • MOODLE_30_STABLE
    • MOODLE_30_STABLE
    • MDL-51993-master
    • Hide

      Before applying the patch (or on non-integration master):

      1. Open course/format/renderer.php
      2. Find the section_edit_control_items() function
      3. At the bottom of the function, comment out the 'attr' value (and ensure you leave syntactically valid PHP)
      4. Open a course page and turn editing on
        1. An exception was thrown
      5. Apply the patch
      6. Refresh the page
        1. Confirm that no exception was thrown
      Show
      Before applying the patch (or on non-integration master): Open course/format/renderer.php Find the section_edit_control_items() function At the bottom of the function, comment out the 'attr' value (and ensure you leave syntactically valid PHP) Open a course page and turn editing on An exception was thrown Apply the patch Refresh the page Confirm that no exception was thrown

      In 'section_edit_control_menu' there is the line:

                      $attr = empty($value['attr']) ? '' : $value['attr'];
      

      if the caller of this method has no 'attr' value in the supplied control, then the 'action_menu_link_secondary' constructor will fail with 'Argument 4 passed to action_menu_link_secondary::__construct() must be of the type array, string given, called in [dirroot]\course\format\renderer.php on line 115'.

      Such as with an input control of:

                      $controls[] = html_writer::link($url, html_writer::empty_tag('img',
                                          array('src' => $this->output->pix_url('i/marker'),
                                                'class' => 'icon', 'alt' => $markthistopic)),
                                          array('title' => $markthistopic,
                                                'class' => 'editing_highlight'));
      

      Which I realise is what it used to be, however, there is still this possibility and the core code to code method call is logically wrong.

      Therefore the code needs to be:

                      $attr = empty($value['attr']) ? array() : $value['attr'];
      

            cameron1729 cameron1729
            gb2048 Gareth J Barnard
            Andrew Lyons Andrew Lyons
            Ryan Wyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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