U4-2223 - Children prpoerty of TypedMedia returns itself when media has no children.

Created by Flavio Spezi 13 May 2013, 12:49:47 Updated by Flavio Spezi 13 May 2013, 15:10:10

Children property of TypedMedia returns itself when media has no children.

var mediaFolder = Umbraco.TypedMedia(idMediaFolder); var list = mediaFolder.Children; foreach (var node in list) { // no children? if (mediaFolder.Id == node.Id) {
Error ! } else {
Done } }

Comments

Sebastiaan Janssen 13 May 2013, 13:07:03

I am unable to reproduce this using the following code in my view (1071 is a Folder with no children, when I do add children I get a list of their Id's, not of the parent):

@inherits UmbracoTemplatePage @foreach (var mediaChild in Umbraco.TypedMedia(1071).Children()) { @mediaChild.Id
}


Flavio Spezi 13 May 2013, 13:43:13

I was used "Children" property, instead of "Children" method. Sorry.


Sebastiaan Janssen 13 May 2013, 14:55:14

This exact code works fine for me, I do not get anything returned.

var mediaFolder = Umbraco.TypedMedia(1071); var list = mediaFolder.Children; foreach (var node in list) { // no children? if (mediaFolder.Id == node.Id) { Error! } else { Done } }


Sebastiaan Janssen 13 May 2013, 15:07:39

Hey Flavio, sorry I was testing on the 6.0.6 nightly and it's actually already fixed there, so you're not going crazy, my fault entirely! This is indeed a bug in 6.0.4 anbd 6.0.5.


Flavio Spezi 13 May 2013, 15:09:18

Maybe this is important? I add this class in "App_Code" folder:

using umbraco.cms.businesslogic.media; public class PhotoNewsMediaFactory : UmbracoImageMediaFactory { public override string MediaTypeAlias { get { return "PhotoNews"; } } }

The typeAlias of folder is "PhotoNewsFolder". It can contains only "PhotoNews" media items. The "PhotoNewsFolder" folder is child of typeAlias "Folder" folder. Umbraco v6.0.5 (Assembly version: 1.0.4869.18012)


Flavio Spezi 13 May 2013, 15:10:10

Ah, ok. Thanks!


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.0.5

Due in version: 6.0.6

Sprint:

Story Points:

Cycle: