Warnings given when no file attached to node.

gnat - April 25, 2008 - 05:13
Project:SWFObject API
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I'm using version 1.2.8 of this module. On the site I'm working on, I am also using Media Mover, FLV Media Player, and XSPF playlist. I am using basic node file attachments to populate the player / playlist on a per node basis. All of this work fine, when there are attachments. When there are not attachments I get the following warnings:

    * warning: array_merge() [function.array-merge]: Argument #2 is not an array in /homepages/44/d88682464/htdocs/sites/dev/mpg/cms/sites/all/modules/swfobject_api/swfobject_api.module on line 93.
    * warning: Invalid argument supplied for foreach() in /homepages/44/d88682464/htdocs/sites/dev/mpg/cms/sites/all/modules/swfobject_api/swfobject_api.module on line 141.

Looking into it, I see that when there are no attachments to the node the $params, and $vars variables for the theme_swfobject_api() function returns a value of "<", which is what causes the array merge errors.

To fix this, I added an if, to make sure that neither $params, or $vars were set to "<", so that the function does nothing if those conditions are not met. I've added the patch. I'm not positive if this is the "right" way to handle this, but it works in the case of node attachments. I can't say what empty cck field values may return.

AttachmentSize
swfobject_api.module.arraymerge.patch852 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.