I have installed the latest versions of filefield and imagefield but get the white screen of death with the following error mesage every time I try to save a node with an image attached:

Fatal error: Call to undefined function field_file_load() in /home/tom/public_html/drupal-6.x/public/sites/codegobbler.com/modules/filefield/filefield_field.inc on line 79

What I have done:

  1. Installed imagefiled - it prompted me to install filefield so I did
  2. added a new imagefield field to the Story node
  3. Created a new Stroy
  4. Uploaded an image (the ajax image upload went fine)
  5. Try to save the new node

And thats when I get the above error. On all subsequent edits of that node (or any other node with an image attached) I get the same error. Once I have the error message on screen, refreshing the page doesn't make it go away, however if I visit another page, and then come back to the node in question, it seems like all the changes I made have been saved, and the image has been successfully attached.

Please excuse me if this issue should have been reported in the imagefield modules bug tracker - The error talks about this module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hunthunthunt’s picture

I get the same problem.

My fix was to add:

module_load_include('inc', 'filefield', 'field_file');

On line 241 of filefield.module (6.x-3.x).

spiffyd’s picture

Status: Active » Reviewed & tested by the community

@#1.. I can confirm that your fix works. A patch needs to be made about this!

drewish’s picture

Status: Reviewed & tested by the community » Needs work

yeah a patch needs to be made before this can be marked RTBC.

hunthunthunt’s picture

Was this fixed in the x4alpha release?

As I am still getting the same bug?

beholder’s picture

Version: 6.x-3.0-alpha3 » 6.x-3.0-alpha4

I have the same bug on alpha4.

drewish’s picture

ica’s picture

i got the same error on line 143

Fatal error: Call to undefined function filefield_field() in /home/site/sites/all/modules/imagefield/imagefield.module on line 143

filefield-6.x-3.0-alpha4.tar
imagefield-6.x-3.0-alpha2.tar
cck-6.x-2.0-rc7.tar
views-6.x-2.0-rc2.tar

also tried with
filefield-6.x-3.0.tar
imagefield-6.x-3.x-dev.tar
gives the same error

-not sure of this error might relate to the imagefield module

what combi of this works at to date?

-thanks
----------------------------------------------------------
- correcting my post above the line

somehow filefield module triggered to disabled while i tried to update different versions, i guess this error was result of filefield was not activated

- at the moment this combination works

imagefield-6.x-3.0-alpha2.tar
filefield-6.x-3.0-alpha4.tar
cck-6.x-2.0-rc7.tar
views-6.x-2.0-rc2.tar

please ignore my post above the line as a bug

Flying Drupalist’s picture

Fatal error: Call to undefined function field_file_load() in /home2/public_html/sites/all/modules/filefield/filefield_field.inc on line 86

I have this problem as well. I'm using:

imagefield-6.x-3.0-alpha2.tar
filefield-6.x-3.0-alpha4.tar
cck-6.x-2.0-rc7.tar
views-6.x-2.0-rc2.tar

and still getting this.

module_load_include('inc', 'filefield', 'field_file');
is already included.

voxpelli’s picture

Status: Needs work » Needs review
FileSize
504 bytes

The fix made by #1 worked for me to. Attaching a patch for it.

drewish’s picture

FileSize
2.43 KB

i've really got no idea why dopry was doing the includes like that. here's a re-roll that should make them a bit saner. could i get someone who'd been running into this problem (i've never encountered it) to test this?

thePanz’s picture

HI, I'm using latest versions of FileField, CCK, Views2 and ImageField and I had the same issue.

Using patch filefield_295620.patch the issue is gone.. I'll let you know about other issues or errors

mrfelton’s picture

I can confirm that filefield_295620.patch fixes the issue.

Latest imagefield, filefield, cck and views

dopry’s picture

Status: Needs review » Reviewed & tested by the community
fractile81’s picture

Status: Reviewed & tested by the community » Needs work

There's now two identical calls of module_load_include('inc', 'filefield', 'filefield_widget'); in filefield_widget_settings();. Otherwise, the patch looks solid.

fractile81’s picture

Version: 6.x-3.0-alpha4 » 6.x-3.0-alpha5
Priority: Normal » Critical

Alpha5 still doesn't have this patch in it. Without it, setups like mine (not sure if there's anything special about it) will not work at all, throwing a Fatal error and causing a WSOD when trying to edit a node with a file field. Bumping the priority -- worth applying despite the duplicate calls I mentioned before (even though it'd be nice to resolve that, it shouldn't hurt anything, right?).

fractile81’s picture

Status: Needs work » Needs review
FileSize
2.14 KB

Attached is a re-roll that also removes the extra include I had mentioned previously.

drewish’s picture

Status: Needs review » Fixed

thanks, committed to HEAD.

Moonshine’s picture

Status: Fixed » Active

I'm afraid there was a method to dopry's madness with some of the original code on this one. :/

filefield_widget.inc is a very important file that FAPI/CCK needs for #process building and re-building of forms with filefields *or* imagefields. My guess is that it was put in the init function for this reason. Without it, very bad things happen after validation fails on a form with imagefields where filefield_widget_process() is needed.

At minimum I think filefield_widget.inc needs to be brought back to init. Drewish you can catch me on #drupal.

drewish’s picture

Status: Active » Needs review
FileSize
1.88 KB

okay, how's this look?

drewish’s picture

Status: Needs review » Fixed

fixes a bug i was running into so i'm committing this.

fractile81’s picture

Status: Fixed » Needs work

I'm getting this error again when I apply this patch. It appears this error can be resolved by adding module_load_include('inc', 'filefield', 'field_file'); in the filefield_field(); function in filefield.module:236. But, if it's being included in filefield_init();, why wouldn't it already be included here?

For clarification, I get this error when I go to edit a node that already has files associated with it (so it has been created with files, then I go back to edit the same node and I get this error).

Moonshine’s picture

Hmm, that sounds very odd. You may want to try tossing a...


drupal_set_message('filefield_init() was called.');

..in filefield_init() and follow it around your site a bit. (Including some form submissions/editing.) If init isn't getting called randomly, then you've certainly got a weird issue that will need further tracking. AFAIK, the only time init isn't called is on fully cached pages.

fractile81’s picture

#7 node_load(222866) called at [F:\home\sites\all\modules\taxonomy_theme\taxonomy_theme_taxonomy.inc:49]
#8 _taxonomy_theme_select_term(1, , educause, node/222866/edit) called at [F:\home\sites\all\modules\taxonomy_theme\taxonomy_theme.module:125]
#9 _taxonomy_theme_assign() called at [F:\home\sites\all\modules\taxonomy_theme\taxonomy_theme.module:17]
#10 taxonomy_theme_init()
#11 call_user_func_array(taxonomy_theme_init, Array ()) called at [F:\home\includes\module.inc:471]
#12 module_invoke_all(init) called at [F:\home\includes\common.inc:2463]
#13 _drupal_bootstrap_full() called at [F:\home\includes\bootstrap.inc:1031]
#14 _drupal_bootstrap(8) called at [F:\home\includes\bootstrap.inc:942]
#15 drupal_bootstrap(8) called at [F:\home\index.php:16]

There's a partial stacktrace when I get the error. Since I'm using the Taxonomy Theme module, it looks like the taxonomy_theme_init(); is being called first, which will cause a node_load(); to happen prior to the filefield_init(); call. At least two options that I can think of:

  1. Solve this at the weight level, and risk this being a problem for some other modules in the future; or
  2. Have anything that might be called in a node_load(); be included when needed.

I'd lean towards the latter since you can reliably control the code, whereas an end user can arbitrarily change their weights (and not know there's a problem until it's too late...). This latter option was also where the original patch was going. What was the other bug that caused the patch to be reverted? Might it have been weight related as well?

Moonshine’s picture

I'd definitely avoid starting the endless weight game, espeically with a cck field module. In the end, these aren't conditional includes anyways. I'd just pull all the module_load_include's out of init and toss them at the top of filefield.module. Then they will all be loaded as part of filefield's base code before any hook init() hits.

Flying Drupalist’s picture

I'm still getting this one on the latest dev. What's a patch that works?

Danial Namousi’s picture

I can confirm this for current dev snapshot.

Fatal error: Call to undefined function field_file_load() in /sites/all/modules/filefield/filefield_field.inc on line 86
maurotn’s picture

I have the same problem if i use filefield with i18n.

TUc’s picture

I'm using FileField 6.x-3.0-alpha5 and imagefield 6.x-3.0-alpha2.

Got the same error:
Fatal error: Call to undefined function field_file_load() in /home2/public_html/sites/all/modules/filefield/filefield_field.inc on line 86

Resolved by simple inclusion of module_load_include('inc', 'filefield', 'field_file') in filefield_field() in filefield.module:

function filefield_field($op, $node, $field, &$items, $teaser, $page) {
  module_load_include('inc','filefield','filefield_field');
  module_load_include('inc', 'filefield', 'field_file');
  $op = str_replace(' ', '_', $op);
  // add filefield specific handlers...
  $function = 'filefield_field_'. $op;
  if (function_exists($function)) {
    return $function($node, $field, $items, $teaser, $page);
  }
}
dopry’s picture

yah I think the code to load field_file.inc will have to be global.... :( oh well i thought I could conditionally include it... Are there any other hooks guaranteed to get called on every page load? I haven't been paying close attention to bootstrap changes lately. at the very least lets always include field_file.inc.

dopry’s picture

why is hook_init not being called though... personallly I haven't been able to reproduce this. These aren't cached pages, are they?

Moonshine’s picture

Well in some of the cases, like #23 above, its just a matter of another module like Taxonomy Theme wanting to do a node_load in its own hook_init. (Which happens to run before filefield)

dopry’s picture

Then I guess it need to go into hook_boot... I tried that locally by failed.. maybe a code registry issue or is that D7?

hunthunthunt’s picture

This may shed some light on the issue:

I've tested the same site on 2 different servers, One running PHP 5.1.6 the other PHP 5.2.X - I only experience the issue on the server running PHP 5.1.6.

Hope that helps :)

hunthunthunt’s picture

I just upgraded PHP 5.1.6 to 5.2.6 and the problem persists. Though I still think this issue has something to do with server config.

Moonshine’s picture

Well the code registry would be in d7, but I think 90% of the stuff here is probably just from it getting loaded after some other module is doing a cck related action like node_load in hook_init. hook_boot may be safe, but at that point it might as well just get loaded with the .module I'd think. Or is there some other condition to worry about?

Flying Drupalist’s picture

#19 worked for me and so I'm hesitant to update to later devs, is this committed yet?

dbeall’s picture

Same issue, i did the fix from comment #10 and it is working now.. sorry, jumped the gun on that..now has error when i try to upload an image..but it will get me to that point.

update: patch 20081009 has everything working well now. and i tested it this time.

virtualdrupal’s picture

I'm on the 10/31 dev and the fix in Post#1 worked for me, or clearing my cache... I'll never know for sure

just glad it's gone

--correction below this line---

An hour or so later I realize I'm getting some type of argument array error, I downgraded to alpha 5 and applied the patch in post #28, this solved both problems for me :)

voxpelli’s picture

Status: Needs work » Needs review
FileSize
361 bytes

A followup to #1 - why not add it in filefield_field_load() where the actual failure is instead of before?

I'm attaching a patch for that. Seems to be working on 6.x-3.0-alpha5 for me.

dopry’s picture

Status: Needs review » Fixed

I went ahead and included field_file.inc at the global level.

ikarusweb’s picture

i have fixed the problem with #39 patch.
thx to all, but we can inside this bugfix in alpha module?

Status: Fixed » Closed (fixed)

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

metagrapher’s picture

Title: Call to undefined function field_file_load() » Call to undefined function module_load_includes()

And now I have this error instead:
Fatal error: Call to undefined function module_load_includes() in /modules/filefield/filefield_field.inc on line 84

it seems I've just swapped one error for the next...

metagrapher’s picture

Status: Closed (fixed) » Active

I should not have changed the title. my bad.

drewish’s picture

looks like it should be module_load_all_includes() or module_load_include()...

drewish’s picture

Title: Call to undefined function module_load_includes() » Call to undefined function field_file_load()
Status: Active » Needs work

metagrapher, i'm guessing you didn't apply the patch but instead typed it in?

metagrapher’s picture

actually, no, I did use patch in solaris. But I did hand copy the patch via vi before applying it. Is it possible that there were non-printable but essential characters that I missed?

metagrapher’s picture

Nope. Did a diff... no difference.

metagrapher’s picture

This is so odd. So the error is ephemeral. I can recreate it every time by creating a new article. Upon saving the article I get this error. This may actually be more closely related with the MetaTags (aka: nodewords) module. Perhaps I should start a thread in their bug queue, as well?

As mentioned earlier in this thread, I think that this error may have something to do with the order the hooks are called. I suppose that perhaps the MetaTags module is doing something before the FileField module is loaded. Alternatively, the MetaTags module is dependent upon the FileField module due to a way that I have views implemented on my site.

I am going to play with some MetaTags patches and see if that gets me anywhere. In the mean time is it possible that the FileField module needs to be called in a specific order? If so, then it is the responsibility of the module to enforce its place, right?

metagrapher’s picture

UPDATE: I have done nothing, but this now works on development, seemingly magically. I don't tend to believe in magic, but I have no other explanation for why this works now. If I come up with a good one though, I'll let you all know! ;)

We'll see how this goes on stage. If it goes well then I will switch the status back to fixed.

metagrapher’s picture

Status: Needs work » Fixed

All good. :)

Status: Fixed » Closed (fixed)

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

jason.fisher’s picture

Version: 6.x-3.0-alpha5 » 6.x-3.x-dev

I experienced this in 6.x-3.7 and 6.x-3.x-dev.. changed it from require_once to include and it went away. Changed it back and the issue did not return.. ?

Unfortunately not much else I can add.

jason.fisher’s picture

Status: Closed (fixed) » Active

Reopening. It happened again, and I can verify that changing the first require_once to an include has corrected the issue.

quicksketch’s picture

yury216’s picture

Version: 6.x-3.x-dev » 6.x-3.9
Assigned: Unassigned » yury216
Status: Closed (fixed) » Active

i have the same problem. I have installed the 6.x-3.9 versions of filefield and imagefield. when i try 2 upload an image attached i have the followin´ error message:

Fatal error: Call to undefined function field_file_urlencode_path() in /var/www/ocu/sites/all/modules/imagefield/imagefield.module on line 377

Can u help me please?

quicksketch’s picture

Category: bug » support
Status: Active » Closed (fixed)

The error you're getting is a different one, and not even in the same module. Please file a new issue.