This error appears during execution of the Channels Entry API in an API extension:
A PHP Error was encountered Severity: Notice Message: Undefined property: EE::$stats Filename: api/Api_channel_entries.php
The API library is loaded successfully:
ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');
and I am making sure the API user has permission (SuperAdmin).
The data array looks like this:
$data = array(
'title' => $tTourTitle,
'field_id_127' => $tTourDuration,
'field_id_136' => $pCountry,
'field_id_137' => "$tTourCity",
'field_id_141' => "$tIncludes",
'field_id_142' => "$tExcludes",
'field_id_143' => "$tNotes",
'field_id_144' => "$tDescription",
'field_id_145' => "$pTour->Opt",
'field_id_149' => $tTourPreferred
);
and I am executing the call according to EE 2.11.1 documentation:
ee()->api_channel_fields->setup_entry_settings($this->aEESettings['experiences_channel_id'], $data);
if($pTourId !== ''){
$updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id'], $pTourId);
} else {
$updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id']);
}
Why would I get this stats object error? Do I need to load any other models/apis to get this working?
Not sure if this matters, but we are using the Structure AddOn.
Thanks in advance for your input.