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

navigation_node_collection -> remove function does not work without $type argument

    XMLWordPrintable

Details

    Description

      This seems broken to me .... I think?

      > public function get($key, $type=null)

      This function will get the data by key, whatever the type is, if you pass null for $type. All great!

      > public function remove($key, $type=null) {

      If you pass null for $type, this will fail to remove the object!

      Worse, it will report the removal as a success by returning true! (I assume that's the point of the "return true"?)

      The culprit seems to be this line in the remove function.

      > if ($node->key === $key && $node->type == $type) {

      This forcibly checks the type, even if you passed null! Shouldn't it be something like:

      > if ($node->key === $key && (is_null($type) || $node->type == $type)) {

      Attachments

        Activity

          People

            Unassigned Unassigned
            ShelterJames ShelterJames
            Andrew Lyons Andrew Lyons
            Dan Poltawski Dan Poltawski
            CiBoT CiBoT
            David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo, Huong Nguyen, Bas Brands, Mathew May
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9/May/16