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

section_edit_control_menu invalid default for $attr

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull Master Branch:
      MDL-51993-master

      Description

      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'];
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cameron1729 cameron1729
              Reporter:
              gb2048 Gareth J Barnard
              Integrator:
              Andrew Nicols
              Tester:
              Ryan Wyllie
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                16/Nov/15