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

Question: explicity set $flags for html_entity_decode function

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 4.2.2
    • Questions
    • None
    • MOODLE_402_STABLE

    Description

      As part of the preparation for PHP 8.2 a compatibility check was run of the existing Moodle LMS codebase (see: MDL-77104). As part of this check the following was raised:

      FILE: /question/engine/renderer.php

      ------------------------------------------------------------------------------------------------------------------------
      FOUND 1 ERROR AFFECTING 1 LINE
      ------------------------------------------------------------------------------------------------------------------------
       183 | ERROR | The default value of the $flags parameter for html_entity_decode() was changed from ENT_COMPAT to
           |       | ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 in PHP 8.1. For cross-version compatibility, the $flags
           |       | parameter should be explicitly set.
      ------------------------------------------------------------------------------------------------------------------------

      That is https://github.com/moodle/moodle/blame/master/question/engine/renderer.php#L183

      To suppress this notification in the future $flags should be explicitly set to `ENT_NOQUOTES | ENT_HTML401 | ENT_SUBSTITUTE` to decode only the HTML entities that are not quotes. i.e.

       

      $trimmed = trim(html_entity_decode($number, ENT_NOQUOTES | ENT_HTML401 | ENT_SUBSTITUTE), " \n\r\t\v\x00\xC2\xA0");

      It doesn't change the existing functionality based on a code assessment, it's just better to be explicit. It also doesn't block PHP 8.2 compatibility for Moodle LMS

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              matt.porritt@moodle.com Matt Porritt
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Clockify

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