If I use a #managed_file element in a custom bean, I get the following error when trying to upload a file (in an alert):

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/fid/form-aS7Vo5fCjL72mNjxW78cd8Fe0yvVUw26HqgxJGUrZk0
StatusText: n/a
ResponseText: 
( ! ) Fatal error: Bean::getForm() [bean.getform]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "featured_video" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in /SITEROOT/sites/all/modules/contrib/bean/includes/bean.core.inc on line 188

Based on the message, I think the #managed_file doesn't have enough information about the custom bean's form to rebuild it correctly. The attached patch fully loads the custom bean's class before returning the form. Is that the best method?

Comments

avr’s picture

StatusFileSize
new333 bytes

Updated patch - uses the built in setPlugin().

indytechcook’s picture

StatusFileSize
new2.71 KB

Is this on new entities? because that method is called with in bean_load_multiple. I've been wanted to rework those loading method for a while. Try this patch

indytechcook’s picture

Status: Active » Needs review

Change status to revew

avr’s picture

Re: new entities - not sure if you mean the actual bean I was editing or "Entity API" module.

Previously, I was testing as I edited an existing bean and was using an older version of Entity API (Beta10).

I've updated to the latest Entity API and I'm getting a similar error as before (on both new and existing beans). It's now moved to the setFields()- here's the full error (including stack trace):

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/fid/form-oHERZfx9I8wl4T_uRzSQdYD4ejahG37g2dSPBYErYFM
StatusText: n/a
ResponseText: 
( ! ) Fatal error: Bean::setFields() [bean.setfields]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "featured_video" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in /Users/avr/Sites/dev.drupal7/sites/all/modules/contrib/bean/includes/bean.core.inc on line 180
Call Stack
#TimeMemoryFunctionLocation
10.0001350808{main}(  )../index.php:0
20.181123250304menu_execute_active_handler(  )../index.php:21
30.181123250800call_user_func_array
(  )../menu.inc:503
40.181123251020file_ajax_upload(  )../menu.inc:0
50.184423442804drupal_process_form(  )../file.module:261
60.196324314324drupal_rebuild_form(  )../form.inc:902
70.196324314324drupal_retrieve_form(  )../form.inc:430
80.196324314948call_user_func_array
(  )../form.inc:773
90.196324315216bean_form(  )../form.inc:0
100.196324317756Bean->getForm(  )../bean.pages.inc:206
110.196324317756Bean->loadUp(  )../bean.core.inc:198
120.196324317756Bean->setFields(  )../bean.core.inc:154

Thanks.

indytechcook’s picture

StatusFileSize
new7.85 KB

Ok, try this patch. It reworks the loading and wakeup of the entity along with loading the plugin at the controller level so we know that all of the PDO issues are out of way.

avr’s picture

For me, this patch fixed the initial issue of file uploads in custom beans.

Hopefully the architectural changes were beneficial, too. Thanks!

indytechcook’s picture

Status: Needs review » Reviewed & tested by the community

Thanks. Changing status to queue it up for commit.

indytechcook’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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