hook override params

tagliavinid - April 21, 2009 - 15:09
Project:FlashVideo
Version:6.x-1.5-rc1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a problem with flashvideo_get_params hook.

The following code in flashvideo.module works only if there is only one hook (e.g flashvideo_cck_flashvideo_get_params in FlashVideo CCk plugin).
Source code:

1          if ($override_params = module_invoke_all('flashvideo_get_params', $file, $file->flags, $params)) {
2            if (count($override_params)) {
3              foreach ($override_params as $param => $value) {
4                $params[$param] = $value;
5              }
6            }
7          }

If I add an hook in another module or another plugin, module_invoke_all return an array merged with php function array_merged_recursive.
The $override_params array will be something like this :

array =
  output_dir: array =
    0: string = "galleria-video/"
    1: string = "galleria-video/"
  originaldir: array =
    0: string = "galleria-video/originali"
    1: string = "galleria-video/originali"
  cmd_path: array =
    0: string = "/Webs/add-ons/ffmpeg/ffmpeg.exe"
    1: string = "/Webs/add-ons/ffmpeg/ffmpeg.exe"
  metadata_cmd_path: array =
    0: string = "/Webs/add-ons/flvtool/flvtool2.exe"
    1: string = "/Webs/add-ons/flvtool/flvtool2.exe"
  video_args: array =
    0: string = "-i @input -f flv -acodec mp3 -ar 22050 -ab 96k @output"
    1: string = "-i @input -f flv -acodec mp3 -ar 22050 -ab 96k @output"
  maxsize: array =
    0: string = ""
    1: string = ""
  thumb_args: array = .....

Line 4 $params[$param] = $value;will produce something like $params["output_dir"] = array(0=> "galleria-video/", 1=> "galleria-video/") and so on..

My fix is to change line 4 in this way.

$params[$param] = (is_array($value)) ? end($value) : $value;

Sorry for my bad english.

#1

EkaMei - April 21, 2009 - 16:04

Seem nice, I will see if I can test it out later.

 
 

Drupal is a registered trademark of Dries Buytaert.