Invalid argument supplied for foreach() on node edit/submit - player not showing up

Manuel Garcia - December 6, 2008 - 16:13
Project:XSPF Playlist
Version:5.x-1.20-alpha3
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

Using:
FLV Media Player 5.x-4.0-alpha9
XSPF Playlist 5.x-1.20-alpha3

If I go to edit a content that has xspf playlist enabled, I see these two errors show up:

* warning: Invalid argument supplied for foreach() in /srv/www/targetmultimedia/sites/all/modules/xspf_playlist/xspf_playlist_node/xspf_playlist_node.module on line 637.
* warning: preg_match() expects parameter 2 to be string, array given in /srv/www/targetmultimedia/includes/bootstrap.inc on line 684.

This is the function where foreach loop is:

<?php
/**
* build a list of the thumbnails, filter
*
* @param object $node drupal node object
* @param array $filter sets the file types
* @return array
*/
function xspf_playlist_node_thumbs($node, $filter = array('jpeg', 'jpg', 'gif', 'png')) {
 
// get all the thumbnails for this node
 
$all_thumbs = xspf_playlist_node_thumb_get_all($node, true);
 
$i = 1;
 
// now filter out the thumbs that we can't use
 
foreach ($all_thumbs as $id => $thumb) {
   
$pathinfo = pathinfo($thumb);
    if (
in_array($pathinfo['extension'], $filter)) {
     
$thumbs[$i] = $thumb;
     
$i++;
    }
  }
 
// add a default option
 
$thumbs[0] = t('Default');

  return
$thumbs;
}
?>

Note that we have setup the default thumbnails to none. Perhaps we need to check wether $all_thumbs has anything in it before looping it? im not a dev sorry :X

-let me know if you need more info -- the player is NOT showing up at all at the moment.

#1

Manuel Garcia - December 6, 2008 - 16:39

Some more information:

The error above appears even if going to the node add page, /node/add/video for example. So it doesn't have to do with having any files uploaded yet.

#2

Manuel Garcia - December 6, 2008 - 16:58

More info, here's what I've tried:

I used the function below instead of the original in xspf_playlist_node.module, basically checking that $all_thumbs is not empty before looping it,

<?php
/**
* build a list of the thumbnails, filter
*
* @param object $node drupal node object
* @param array $filter sets the file types
* @return array
*/
function xspf_playlist_node_thumbs($node, $filter = array('jpeg', 'jpg', 'gif', 'png')) {
 
// get all the thumbnails for this node
 
$all_thumbs = xspf_playlist_node_thumb_get_all($node, true);
 
$i = 1;
 
// now filter out the thumbs that we can't use
 
if (!empty($all_thumbs)){
    foreach (
$all_thumbs as $id => $thumb) {
     
$pathinfo = pathinfo($thumb);
      if (
in_array($pathinfo['extension'], $filter)) {
       
$thumbs[$i] = $thumb;
       
$i++;
      }
    }
  }
 
// add a default option
 
$thumbs[0] = t('Default');

  return
$thumbs;
}
?>

This results in the first error not showing up , but the second one, still appearing:

warning: preg_match() expects parameter 2 to be string, array given in /srv/www/targetmultimedia/includes/bootstrap.inc on line 684.

Hope this helps, but right now I am kinda lost on what could be going on here.

Any pointers?

#3

ranavaibhav - December 13, 2008 - 18:43

I have exact same configuration and receiving same errors.. Please help!!
Thank you...

#4

gggdrpl - December 14, 2008 - 06:56

Same problem using:

FLV Media Player 5.x-4.0-beta1
XSPF Playlist 5.x-1.20-alpha3

Any clue, please? Thanks!

#5

arthurf - December 14, 2008 - 17:41

The fix for the foreach is in cvs, looking into the pregmatch issue.

#6

arthurf - December 15, 2008 - 18:59

warning: preg_match() expects parameter 2 to be string, array given in /srv/www/targetmultimedia/includes/bootstrap.inc on line 684.

Fix for this is in CVS

 
 

Drupal is a registered trademark of Dries Buytaert.