dmCategory.getCategoryBranchAsList() always includes the submitted category


In the FC 7.2.9 release, the dmCategory’s getCategoryBranchAsList() method only takes a list of category IDs as input. However, later in the code, it calls the getDescendants() method with the parameter bIncludeSelf set to “true” (see below).

	<cffunction name="getCategoryBranchAsList" returntype="string" access="public" hint="Get all the descendants of the categoryids passed in." output="false" bDocument="true">
	<cfargument name="lCategoryIDs" type="string" required="true" hint="List of categoryIDs to expand.">


	<!--- get all descendent categories --->
	<cfloop list="#arguments.lCategoryIDs#" index="i">
		<cfset q = application.factory.oTree.getDescendants(objectid=i, bIncludeSelf="true")>

Since the method might also be called with the idea of only returning a submitted categoryID’s children (descendants), I would suggest to allow setting of the bIncludeSelf value as optional parameter:

<cfargument name="bIncludeSelf" type="boolean" default="true" hint="include the parent in the list">

and to alter the getDescendants() call as follows:

<cfset q = application.factory.oTree.getDescendants(objectid=i, bIncludeSelf=arguments.bIncludeSelf)>

This solution allows for more flexibility while at the same time keeping the current behavior.

– Thomas