Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9.1
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      30994

      Description

      The navmenu() function makes a change to the $modinfo variable obtained by get_fast_modinfo. The $cms[id] entry for the current module has its name overwritten to 'Jump to...'.

      These changes are intended to be local to the function, however it is actually working on a reference to the cached modinfo which means that anyone who calls get_fast_modinfo later gets the messed-up data!

      I don't know if this has any code effect in moodle 1.9 but as it is a bugfix maybe is worth doing. Should definitely go into head.

      I have attached the patch - simplest/most efficient fix was simply to save the previous value and restore it afterwards (rather than trying to clone the variable or anything).

      1. navmenu.patch
        1 kB
        Sam Marshall
      2. navmenu2.patch
        2 kB
        Sam Marshall
      3. navmenu3.patch
        2 kB
        Sam Marshall

        Activity

        Hide
        Sam Marshall added a comment -

        Eloy pointed out a much better way to do this (by stopping it altering $modinfo at all). This is in navmenu2.patch, attached.

        Show
        Sam Marshall added a comment - Eloy pointed out a much better way to do this (by stopping it altering $modinfo at all). This is in navmenu2.patch, attached.
        Hide
        Sam Marshall added a comment -

        We both realised there were other things wrong with this code as well: first there were other places where it altered $modinfo data, second it did incorrect things with the module name:

        1) Used non-mb string functions to cut down the length of long module names, this caused breakage on Japanese characters etc.

        2) Used unnecessary urldecode on module names, this caused breakage if you had a module with e.g. %20 in the name

        Here is another patch which also addresses these issues.

        Show
        Sam Marshall added a comment - We both realised there were other things wrong with this code as well: first there were other places where it altered $modinfo data, second it did incorrect things with the module name: 1) Used non-mb string functions to cut down the length of long module names, this caused breakage on Japanese characters etc. 2) Used unnecessary urldecode on module names, this caused breakage if you had a module with e.g. %20 in the name Here is another patch which also addresses these issues.
        Hide
        Sam Marshall added a comment -

        Committed to 1.9 and HEAD. (Eloy and I both tested, including the previous failure situations mentioned above.)

        Show
        Sam Marshall added a comment - Committed to 1.9 and HEAD. (Eloy and I both tested, including the previous failure situations mentioned above.)
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Verified. Closing. Thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Verified. Closing. Thanks!
        Hide
        Petr Škoda added a comment -

        thanks!

        Show
        Petr Škoda added a comment - thanks!

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: