I was having issues viewing nodes with Media Field fields, and tracked it down to this. I believe the problem arises from the fact that the _field_field_load() function is declared in multimediafile.inc, which is included by the hook_field() function. This hook isn't always called though, cached pages for example, and thus caused problems. This patch should take care of it. There's also an existing issue for the 4.7.x version of this module. I'm guessing the same fix would work there.

Comments

eojthebrave’s picture

StatusFileSize
new2.37 KB

Oops. I diffed in the wrong direction. This one is correct. Sorry about that, I'm still kind of new to this.

ardas’s picture

Do you think including INC file in init hook is better than in every CCK hook?
Including php file in init hook means it will be included when all modules are loaded even when it is not needed.

ardas’s picture

I still can't reproduce this issue in 5.0. I include this file in three functions (CCK hooks):
1. function audiofield_widget()
2. function audiofield_field()
3. function audiofield_widget_settings()

I wonder, isn't it enough and in which cases the problem occurs? Could you describe me your scenario? Thanks.

eojthebrave’s picture

Here's what has been happening to me. I create a new node with an audio field, and the first time I view that node everything works fine (pre-cache). If I try and view the node again it's pulling it from the cache table, and then throws the undefined function error when the audiofield_field_formatter function gets called as this function calls the _field_file_load function (line 316 of audiofield.module).

The reason I think it has something to do with the cache table is that if I empty my cache table I'm able to view the page once (before the cache gets created) however all subsequent attempts to view the page fail. I'm not really sure why this is happening, I don't even have caching turned on at this point, yet the problem continues.

I don't necessarily think including the INC file in hook_init is the best option, but it's what worked for me at the time. There may be a better way to go about it that I am unaware of.

Let me know if there are any other details I can provide.

ardas’s picture

Yeah. Looks like formatter hook was the last one where multimediafile.inc wasn't included. I wonder, why it worked for the first time:) May be because widget hook is called for the first time. Okay, I put require_once into the formatter hook (HEAD, 4.7, 5.0). Please download the latest release when it is ready and try pass your scenario. I hope it should help. I prefer to avoid including this file in the hook_init() because of two reasons:
1. Theriotically, it is a bad practice to include everything in the beginning because for most page loads this file is not needed.
2. In Drupal 5.0 there is an aggressive cache and if modules implement init or exit hooks they are not compatible with agressive cache! So, I am trying to avoid them when possible.

Thanks for your help.

ardas’s picture

Status: Needs review » Fixed
joachim’s picture

I've just downloaded and installed the latest release, 5.x-1.x-dev 2007-Feb-22 15.09 KB
I still get the problem:

Fatal error: Call to undefined function: _field_file_load() in /home/seasider/public_html/drupal5/sites/all/modules/mediafield/audiofield.module on line 316

ardas’s picture

It is hardly possible. I've just downloaded the 5.0dev release and there is a
require_once(drupal_get_path('module', 'audiofield') .'/multimediafile.inc');
in function audiofield_field_formatter() and must not get this error when calling _field_file_load() function.

You probably have an old version.

Anonymous’s picture

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

I am an absolutely newbie to drupal, and i met the error which is "Fatal error: Call to undefined function _field_file_load() in E:\www\modules\mediafield\audiofield.module on line 316"
seems this patch could save my life, but the problem is how to use the patch ??

any reply would be appreciated !

panis’s picture

go line 316 and right before the line that says _field_file_load() add the following:
require_once(drupal_get_path('module', 'audiofield') .'/multimediafile.inc');

headkit’s picture

thanx! this worked for me.

headkit’s picture

but how do I push the uploaded songs into a player?

Petuschki’s picture

Title: Fatal error: Call to undefined function: _field_file_load() in 5.x.* » I find it really problematic...

well, this problem is known at least since last may 07
I downloaded the module and installed it in January 08
the error was still there
then I had to search around to find this thread
I edited the file and included the "require_once" in the module and the error was gone

instead of that now I get the message "getid3 library not found!" from time to time
before the library was found

let me express my deep frustration: I understand the possibilities and structure of Drupal, and that is the reason why I try since some weeks now to create a Drupal environment where the simplest things like a working editor, including multimedia files etc. will be provided

it is not the complexitiy of Drupal, that makes life so hard, it is the horrible maintenance of the modules etc...

what to do now with this error message?
Uninstall everything and experiment with the next MultimediaModule which will throw out other unexpected messages and errors?
As I said, I am deeply frustrated ;=(

ardas’s picture

Guys, sorry for not maintaining this module for a long time. Unfortunatly, we have no people for this work ni the company. In the nearest future I'm going to maintain it again, apply patches and develop a D6.0 version.

Also, there is a discussion with Dopry who developed a filefield.module about our INC file with common functions. Dopry said all these functions will be included in his filefiel.module but it wasn't done yet as I know. I'm starting to pushing this question ahead.