in line 145 there is an array merge which is supposed to merge $items_mp4 and $items_others. If I only have one item defined, and that one is mp4, then the array merge call results in an actually empty array. Seems like an odd behaviour of array merge.. but that needs some testing, to fully understand what is happening.

What solved the bug here is to use array_splice to add an array to the end of the other.

array_splice($items_mp4, count($items_mp4), 0, $items_others);
$vars['items'] = $items_mp4;

I also think that some issues posted on the issue queue might be related to this bug, actually.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valderama’s picture

Assigned: Unassigned » valderama
Status: Active » Needs review
FileSize
589 bytes

I could reproduce the bug again on a completely clean install. Basically if you just have one video item, none gets printed because of the unwanted behavior of array_merge.

Attached there is a patch against dev.

aethr’s picture

I ran into this bug today as well. This is due to the fact that array_merge only accepts arguments of type array, if $items_others is NULL (ie it hasnt been defined) then array_merge will fail.

This could also be fixed by simply casting both variables as array:

$vars['items'] = array_merge((array)$items_mp4, (array)$items_others); // mp4 listed first
valderama’s picture

I see, so that is the reason why array_merge fails. I changed the patch accordingly. Now both array get initialized properly. As it is done in the D7 version - so I thought that is the best way.

Hope it will get comitted!

Jorrit’s picture

Status: Needs review » Reviewed & tested by the community

Works for me.

Jorrit’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 6.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

updated