Bug #23073 See Comments

Api_channel_entries requires you to load “stats” library

Version: 3.3.0 Reporter: lkdennis

This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report

Maybe I’m using this wrong, but I went from the example given.



     $data = array();
     $data['title'] = ee()->input->post('post_title');
     //$data['entry_date'] = ee()->input->post('date');
     $data['field_id_2'] = ee()->input->post('job_title');
    $data['field_ft_2'] = 'none';

    ee()->api_channel_fields->setup_entry_settings(2, $data);

    $success = ee()->api_channel_entries->save_entry($data, 2);
    if ( ! $success)
', $this->api_channel_entries->errors)));

This kept giving me a html response with the error “Exception Caught: No such property: ‘stats’ on EllisLab\ExpressionEngine\Legacy\Facade”.

So I found someone else had to add the ‘stats’ library to get it to work.


Is this something specific to the way I’m using this in my extension or should it be added to the documentation?

  • What’s the context and desired functionality? That library is automatically loaded very early. Are you taking these actions in an extension hook?

    Derek Jones
    20th April, 2017 at 5:50pm
  • Yes the the extension works on a “sessions_start” hook.

    20th April, 2017 at 5:58pm
  • What’s the context and desired functionality? From your code snippet it doesn’t look like you are modifying or manipulating the user’s session, so I do not think you are using the best hook for the task.

    Derek Jones
    20th April, 2017 at 6:02pm
  • I’m implementing an API to create and modify entries. So I hook the session and watch for an ‘api’ trigger url.

    Similar to this: https://github.com/putyourlightson/open-api/tree/master/open-api/system/expressionengine/third_party/open_api

    20th April, 2017 at 6:07pm
  • Gotcha. Ideally that would happen via an ACTION request rather than on PAGE calls to a template. But I understand that that leaves you with less controllable URLs, or would require additional server config on the user’s part. So if you continue down the path of using an extension hook, core_boot is the one you want. Session hooks are for modifying the session object itself. It executes far too early for general application behavior, and is not meant for anything other than that purpose. With core_boot, it happens early, but after the app is ready to use. Make sense?

    Derek Jones
    20th April, 2017 at 6:29pm
  • Got it.

    It seems I’ll need to implement an XID when posting with the core_boot hook, but not a big deal.

    Thanks for your help.

    20th April, 2017 at 6:44pm
  • That’s another reason to use ACTIONs, fwiw, they can be exempted from CSRF in situations where the POST might be coming from some external system.

    Derek Jones
    20th April, 2017 at 6:46pm
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases