1

I've got a custom fieldtype I need to upgrade for EE 2.5.5 - It uses the Tools model, which was deprecated in EE 2.2. Here's the code that's coughing up errors in the developer log:

$upload_prefs = $this->EE->tools_model->get_upload_preferences($this->EE->session->userdata('group_id')); foreach ($upload_prefs->result() as $row) $upload_dirs[$row->id] = $row->name;

And here's the error:

The system has detected an add-on that is using outdated code that may stop working or cause issues with the system. What does this mean? Deprecated function get_upload_preferences() called in C:\Program Files\EasyPHP-12.1\www\EE\system\expressionengine\third_party\custom_fieldtype\ft.custom_fieldtype.php on line 272. Deprecated since 2.2. Use File_upload_preferences_model::get_file_upload_preferences() instead.

I've tried replacing tools_model->get_upload_preferences with file_upload_preferences_model->get_file_upload_preferences, but that gives us this:

Fatal error: Call to a member function result() on a non-object in C:\Program Files\EasyPHP-12.1\www\EE\system\expressionengine\third_party\custom_fieldtype\ft.custom_fieldtype.php on line 273

Any ideas how to fix this?

1 Answer 1

1

Again I am trying to resolve your problem :)

You should update your code like:

$this->EE->load->model('file_upload_preferences_model');
$upload_prefs = $this->EE->file_upload_preferences_model->get_file_upload_preferences($this->EE->session->userdata('group_id'));

/***
$upload_prefs itself an array having all the upload preferences.
***/

foreach ($upload_prefs as $row)
{
$upload_dirs[$row['id']] = $row['name'];
}

I hope, it would help. Plz post your further comments if it didn't work.

3
  • Looks like it's working, one more problem though - I've got a couple of lines causing an error message: $directory_info = $this->EE->file_upload_preferences_model->get_file_upload_preferences($group_id, $upload_location); $server_path = $directory_info->row('server_path'); and the error: http://127.0.0.1/EE/admin.php?S=64003fd21507ab78df83e67007b714fdb91cf930&D=cp&C=content_publish&M=entry_form&channel_id=2 Apr 22, 2013 at 10:29
  • @ninjachicken1: I could share the error message text. In your comment, you shared the CP link your localhost ;) . Apr 22, 2013 at 15:12
  • Doh! I think it may be fixed now as I'm not getting the error anymore, I'm now testing it. Apr 22, 2013 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.