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

format_string called with context instead of an array with a context

XMLWordPrintable

      Discovered in MDL-80072 when I added type hints.

      In a small number of places, we're passing a context in to the $options argument of format_string which means that the string is not filtered properly. It should be ['context' => $context].

      At the moment we always cast $options to an array, which means that we end up with a set of values which have the internal properties of the context, but does not get applied to the filter correctly.

      This has a mixed impact depending on site configuration, and the filters at play. One possible implication is that the wrong filters can be applied in these cases. Typically the $PAGE->context is used as a fallback, and in several of the cases I looked at, this was the system context.

      This changeset:

      • fixes those cases currently doing this;
      • adds a debugging notice when this is detected; and
      • converts the context to the correct format.

      Whilst we could get away with not adding the debugging notice, this is wrong, and it needs to be fixed for people running third-party code on other branches. Adding a debugging notice will mean these cases can be picked up, and properly fixed.

      Note: There may be more cases that I have not detected. This change only fixes those picked up by phpunit and behat.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Paul Holden Paul Holden
            Shamim Rezaie Shamim Rezaie
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 40 minutes
                5h 40m

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