In flashvideo_cron() in the flashvideo.module, the $file object is modified by the called code. Since this is passed by reference in PHP 5, the second call to flashvideo_convert() will get a file object with the information for the jpeg thumbnail:

if($params['create_thumb']) {
flashvideo_convert($file, $type->type, TRUE, $params);
}

// in PHP 5, $file has been modified and contains the thumbnail information,
// not the original file information

if($params['create_video']) {
flashvideo_convert($file, $type->type, FALSE, $params);
}

One solution is to add the following before that code:

$originalFile = drupal_clone( $file );
$originalFileFid = $originalFile->fid;

Then, use $originalFile in the second call to flashvideo_convert, and use $originalFileFid in the following database update code.

Comments

travist’s picture

I need some help making sense of this... You said that the $file object is passed by reference, but I do not see where you are describing this. I do not see anywhere where I pass the object like flashvideo_convert(&$file... ). Everywhere I use this it is passed using flashvideo_convert($file.... ) and not with a reference.

tolstoydotcom’s picture

In PHP5, I believe that all objects (like the $file object above) are passed by reference. That doesn't apply to non-objects like arrays:

drupal.org/node/84430
http://www.blueshoes.org/en/blog/?blogMessageID=2

travist’s picture

Ok, well if that is the case, then from what I see, there still isn't a problem with the code. I did a search for any instances of where I actually change a variable within the $file object within the function flashvideo_convert and saw no instances of $file = .... or $file->param = .... which would cause a problem if the variable was passed by reference. The only indication that I see is when I create a new variable called $newfile = $file;, and then change that variable. But then $newfile is just a copy and not a reference... OR IS IT!?

I still cannot see any conflict with what I wrote with PHP5. I might need you to elaborate a little more... my apologies.

tolstoydotcom’s picture

I'm pretty sure that after that assignment $newfile would just be what $file is: a reference. The best way to see this would be to print_r $file before and after the first call to flashvideo_convert, installing PHP 5 locally if necessary. At least on my setup, when the first call returns from flashvideo_convert(), the $file object contains the thumbnail information (a .jpg file, not the movie file it was before the call).

travist’s picture

That is so strange... It is beyond me why the PHP committee did this. Coming from the world of C++ where every assignment is done explicitly (reference, pointer, copy, whatever), this just boggles my mind. How about this... Instead of saying $newfile = $file, I will simply replace it with $newfile = drupal_clone($file); This should work, right?

Thanks again for your help.

travist’s picture

Status: Active » Fixed

Version 2.2-Beta3 should fix this problem...

Anonymous’s picture

Status: Fixed » Closed (fixed)
chrisschaub’s picture

removed, posted to wrong thread