Dnn.Platform icon indicating copy to clipboard operation
Dnn.Platform copied to clipboard

Fixed DDRMenu to handle duplicate page names

Open daguiler opened this issue 4 years ago • 2 comments
trafficstars

Fixes #4483

Summary

The bug is located here (irrelevant parts omitted for brevity):

image

The FilterNodes function cycles through the names specified in the "IncludeNodes" attribute (available in the nodeTextStrings variable). For each of these names, it invokes the FindByNameOrId function of the root node of the menu. The idea is to populate the filteredNodes list with all the nodes that we need to preserve. Later on, the RemoveAll(<predicate>) function is called, which takes care of removing all items of the menu that are not present in this list.

The problem is that FindByNameOrId just returns the first node that meets the criteria. When several pages share a common name, only the page that is found first survives this purge.

The solution I analyzed first was changing FindByNameOrId to return a list of all matching nodes, and not just the first node that satisfies the condition. However, this function is a public function referenced from several places. Changing its signature would be a breaking change.

So I chose to create a new function for this purpose (FindAllByNameOrId) and modify FilterNodes to call this new function instead.

daguiler avatar Feb 11 '21 12:02 daguiler

Cool, thanks for the fix :-)

Timo-Breumelhof avatar Feb 12 '21 10:02 Timo-Breumelhof

It would be a bit of a breaking change for some sites. I assigned this to Dnn10 for that reason.

valadas avatar Feb 16 '21 20:02 valadas