Upgrading to php-5.3 renders swftools' onepixelout unusable with barking like these:

warning: Parameter 2 to onepixelout_swftools_flashvars() expected to be a reference, value given in /path/to/drupal/includes/module.inc on line 450.

Removing the ampersands from onepixelout_swftools_flashvars()'s definition renders swftools' onepixelout usable again - which is what the attached patch does.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NaheemSays’s picture

Status: Needs review » Reviewed & tested by the community

Tested and this fixes the problem. (Drupal core was also fixed with similar changes in drupal 6.14 I think).

Similar changes will also need to be done for all the modules that use hook_swftools_flashvars.

Stuart Greenfield’s picture

Hmm. You learn something new every day!

The hook_swftools_flashvar is written using references because in some cases (e.g. FlowPlayer 3) the module wants to change other things, like the embedding method being used.

I never formally checked at the time I put this in, and it has worked up until now. But now I've done some reading I've found descriptions that warn that module_invoke() can't be used to pass by reference, although that's what I'm doing, and it seems to be working [it is how FlowPlayer3 module can over-ride the default embedding setting mode and force its own]

Similar is described at http://api.drupal.org/api/function/user_module_invoke/6 which is a specific function call for invoking hook_user.

At the moment my test set up is PHP 5.2 (primarily because the Zend debugger doesn't like PHP 5.3), but I will have a go at implementing a version of user_module_invoke as a solution.

I'm puzzled though - the documentation says module_invoke can't handle references, but it seems to be work for me...!!

Stuart Greenfield’s picture

OK - set up PHP 5.3 and yes, it starts to complain.

Rather than remove the pass by reference and break the ability of FlowPlayer3 to over-ride the embedding, which is a necessary capability to support some advanced FP3 things that are coming, I've written an alternative function to call the hook, in a similar vein to user_module_invoke. It's a little simpler because we know the module we're calling.

Upshot is that passing by reference now works without any complaints from PHP.

This code is on branch DRUPAL-6--3 as I anticipate this is where the next release will come from.

To implement the fix manually to an existing SWF Tools installation change line 500 in swftools.module from:

// Get player flashvars
$player_flashvars = module_invoke($resolved_methods->player['module'], 'swftools_flashvars', $action, $resolved_methods, $vars);

to

// Get player flashvars - use a custom invoke to allow pass by reference
$player_flashvars = swftools_flashvars_invoke($action, $resolved_methods, $vars);

and add this new function at the end of the swftools.module:

/**
 * Invokes hook_swftools_flashvars() in the relevant player module.
 * 
 * We cannot use module_invoke() for this, because the arguments need to be passed by reference.
 * 
 * @param $action
 *   String defining the action that is to be performed, eg SWFTOOLS_FLV_DISPLAY
 * @param &$methods
 *   Object containing two keys - player and method. Each consists of an array
 *   that defines the details of the resolved player and embedding method that
 *   is being used for this file.
 * @param &$vars
 *   Object containing three keys - othervars, flashvars and params. These are
 *   arrays containing key/value pairs that contain all the data assigned to this
 *   file so far. Refer to swf() for more details about the $vars array.
 * @return
 *   Return an array of flashvars needed to allow the player to work.
 */
function swftools_flashvars_invoke($action, &$methods, &$vars) {

  // Build the name of the function we are going to call
  $function = $methods->player['module'] . '_swftools_flashvars';
  
  // Call the function and return the resulting flashvars to the caller
  return($function($action, $methods, $vars));

}

Note to self - this issue isn't fully resolved yet - there are other calls to swftools hooks (e.g. hook_swftools_playlist) that also rely on module_invoke by are written to receive parameters by reference.

rdgouw’s picture

Thanks for adding this solution! No complaints by PHP 5.3 anymore.

AndyF’s picture

And the same thing as a patch...

DanWoodbury’s picture

hi, thanks for the help so far but i still cannot get this to go. the original errors have gone but now i get a new error (in error reports) saying that the system cannot find AC_RunActiveContent.js.

the weirdest thing is that the path shown is depenedent on the video path.

any help would be appreciated

carlitos.10040’s picture

Thank you Stuart, this worked.

mathieu’s picture

Subscribe

dkane’s picture

Patch in #6 worked for me. Thank you andy.

jacobkdavis’s picture

Patch in #6 worked for me too, thanks Stuart and Andy! Will this be rolled into the next version?

rachawal’s picture

Stuart, thank you very much for providing a clear and concise resolution to this issue. I encountered the same issue, and after I implemented your change, Flowplayer appeared and played videos! Thank you, thank you, thank you!!!

Brian Tastic’s picture

I used the manual method as described above and that seemed to cure some of the problems. Thanks.

rv0’s picture

patch in #6 works for me

stawil’s picture

Stuart Greenfield you are awsome.
your code is saved me.
Big thanks.

John Franklin’s picture

As noted in #907464: Parameter 2 to genericplayers_swftools_flashvars() expected to be a reference, objects are always passed by reference, so there's no need to create a special invoke mechanism.

dbavedb’s picture

Stu is the man... all this stuff was broken for me all day. Hah I thought I could just work around it (JW player worked, but Flowplayer would not). Thanks!

-PHP/Drupal newb

dmakaridze’s picture

Subscribe

abaddon’s picture

had issues with php 5.3 (the error in the logs got me here - my problem was that the 1pixelout players were not stopped when starting another) and the patch in #6 fixed it for me

hefox’s picture

Status: Reviewed & tested by the community » Needs work

Needs working based on comment #16; no need to have more code than necessary!

mtift’s picture

Status: Needs work » Needs review
FileSize
2.89 KB

This patch, formatted for Git, fixed the problem for me.

Dexter8’s picture

Worked for me. I edited the following files in swftools module. Remove & symbol for function wijering_swftools_flashvars($action, $methods, $vars)

/sites/all/modules/swftools/flowplayer/flowplayer.module
/sites/all/modules/swftools/flowplayer3/flowplayer3.module
/sites/all/modules/swftools/genericplayers.module
/sites/all/modules/swftools/imagerotator/imagerotator.module
/sites/all/modules/swftools/onepixelout/onepixelout.module
/sites/all/modules/swftools/simpleviewer/simpleviewer.module
/sites/all/modules/swftools/wijering/wijering.module
/sites/all/modules/swftools/wijering4/wijering4.module

ryan.gibson’s picture

Status: Needs review » Reviewed & tested by the community

Functionally, #21 cleared up the issue for me. Not receiving the error anymore.

NaX’s picture

Version: 6.x-2.5 » 6.x-2.x-dev
Status: Reviewed & tested by the community » Fixed

It looks like this was committed to the dev branch in 2010
Ref: http://drupalcode.org/project/swftools.git/commit/2f5cdfafe7870e9162abc1...

Status: Fixed » Closed (fixed)
Issue tags: -PHP 5.3

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

benlotter’s picture

#3 worked for me, thanks.

yan’s picture

Issue summary: View changes

#21 works for me, but I'm amazed that there hasn't been a new release since almost five years.

fuzzy76’s picture

Reroll against latest stable.