0

TLDR, recently updated from EE2x to EE5x

We have some code to easily duplicate entries by using the EE API.

The short version of the code:

ee()->load->library('api');
ee()->legacy_api->instantiate('channel_entries');
ee()->legacy_api->instantiate('channel_fields');

ee()->api_channel_fields->setup_entry_settings($channel_id, $entry_data);

$success = ee()->api_channel_entries->save_entry($entry_data, $channel_id);

if(!$success)
    {
         return show_error(implode('<br />', $this->api_channel_entries->errors))
    }

Which works perfectly fine when a SuperAdmin runs this piece of code via button. No error, nothing but success!

However, all other users, not belonging to EE's superAdmin member group that attempt to run this code trigger an error that's a bit difficult to decipher.

{"messageType":"error" "message":"No such property: 'status_model' on EllisLab\ExpressionEngine\Legacy\Facade" "trace":["#0 ee/EllisLab/ExpressionEngine/Legacy/Facade.php(30): EllisLab\ExpressionEngine\Legacy\Facade->get('status_model')" "#1 ee/legacy/libraries/api/Api_channel_entries.php(823): EllisLab\ExpressionEngine\Legacy\Facade->__get('status_model')" "#2 ee/legacy/libraries/api/Api_channel_entries.php(111): Api_channel_entries->_check_for_data_errors(Array)" "#3 ee/legacy/libraries/Functions.php(627) : eval()'d code(195): Api_channel_entries->save_entry(Array'16')" "#4 ee/legacy/libraries/Functions.php(627): eval()" "#5 ee/legacy/libraries/Template.php(2018): EE_Functions->evaluate('{!-- ra:0000000...')" "#6 ee/legacy/libraries/Template.php(591): EE_Template->parse_template_php('{!-- ra:0000000...')" "#7 ee/legacy/libraries/Template.php(236): EE_Template->parse('{!-- ra:0000000...',false,1,false)" "#8 ee/legacy/libraries/Template.php(167): EE_Template->fetch_and_parse('',Array,false)" "#9 ee/legacy/libraries/Core.php(661): EE_Template->run_template_engine('','')" "#10 ee/legacy/controllers/ee.php(63): EE_Core->generate_page()" "#11 [internal function]: EE->index()" "#12 ee/EllisLab/ExpressionEngine/Core/Core.php(241): call_user_func_array(Array,Array)" "#13 ee/EllisLab/ExpressionEngine/Core/Core.php(110): EllisLab\ExpressionEngine\Core\Core->runController(Array)" "#14 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))" "#15 index.php(174): require_once('...')" "#16 {main}"]}

I'm open to any ideas, google has been quite the let-down in terms of any EE5 support.

1
  • The only reference to a potentially similar problem i found was. -- As of ExpressionEngine 4, the legacy Channel Entries API isn't viable for inserting/updating entries as it doesn't account for the new database schema. It's recommended you use the ChannelEntry model instead. – ipixel Dec 11 '20 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.