EE v2.9.0 Build Date: 20140715
This error displays about 44 times after submitting an entry with a white screen when using the entry_submission_end
hook. I have roughly 20 field types enabled, and 37 fields created. This is across all field groups.
I've uninstalled everything to the bare bones besides the playa field that I'm working with.
I am using the entry_submission_end hook with ee()->api_channel_entries->save_entry
inside a foreach loop.
A PHP Error was encountered
Severity: Notice
Message: Undefined index: field_type
Filename: api/Api_channel_fields.php
Line Number: 299
The $data
is the $_POST data array that is passed via the entry_submission_end
hook. Made sure all my fields are mapped properly.
print_r($added_playa_entries);
Outputs
Array
(
[0] => Array
(
[title] => test 1
[url_title] => test-1
[entry_id] => 9
)
[1] => Array
(
[title] => test 2
[url_title] => test-2
[entry_id] => 10
)
[2] => Array
(
[title] => test 3
[url_title] => test-3
[entry_id] => 12
)
[3] => Array
(
[title] => test 4
[url_title] => test-4
[entry_id] => 16
)
)
The Code
foreach($added_playa_entries as $key => $val)
{
unset($playa_data);
$playa_daya = array();
$playa_data['title'] = $added_playa_entries[$key]['title'];
$playa_data['url_title'] = $added_playa_entries[$key]['url_title'];
$playa_data['entry_id'] = $added_playa_entries[$key]['entry_id'];
$playa_data['status'] = 'open';
$playa_data['category'] = $data['revision_post']['category'];
// These are custom fields
$playa_data['field_id_33'] = $data['revision_post']['title'];
$playa_data['field_id_34'] = $data['field_id_16'];
$playa_data['field_id_35'] = $data['field_id_21'];
$playa_data['field_id_36'] = $data['field_id_32'];
$playa_data['field_id_37'] = $data['revision_post']['url_title'];
if ( ! ee()->api_channel_entries->save_entry($playa_data, 4, $playa_data['entry_id'], FALSE))
{
var_dump(ee()->api_channel_entries->get_errors());
exit();
}
}
Here is what I am saving using the ee()->api_channel_entries->save_entry method.
print_r($playa_data);
For example outputs. The $added_playa_entries
example above does not correlate with the result below. This is simply an example.
Array
(
[title] => Test Entry
[url_title] => test-entry
[entry_id] => 7
[status] => open
[category] => Array
(
[0] => 4
[1] => 5
[2] => 22
)
[field_id_33] => Field id 33 data here
[field_id_34] => Field id 34 data here
[field_id_35] => Field id 35 data here
[field_id_36] => Field id 36 data here
[field_id_37] => Field id 37 data here
)
Field id's 33-37 are just text fields.
No fields are marked as required, I double checked this in the DB.
For some reason this will work when I delete a single entry using the hook delete_entries_start
. When an entry is deleted, all related child entries of the deleted entry are set to closed, categories are cleared, and the custom field data of child entries is removed within the same similar foreach loop. I'm not even operating DRY right now because it's not working with the entry_submission_end
hook method.
The data does save for every entry successfully, however the mentioned error appears 44 times with a white screen on entry_submission_end while using the ee()->api_channel_entries->save_entry
inside a loop when using this hook.
What I want to know - can you replicate this? Am I missing the minuscule mistake, I have a hunch it's a bug within the channel entries api. Is it playa? I don't know yet. I've disabled all modules but Playa, but still can't seem to get this to work.
UPDATE
Performed upgrade to EE 2.9.2. Found that Line Number 299 is the culprit in the Api_channel_fields.php file. Why are field_type indexes not appearing? No clue as it seems to try and grab these indexes for fields that are not even associated with the channel. This is something for Ellislab to look into.
$field_id = $field_type;
$field_type = $this->settings[$field_id]['field_type'];
Within the elseif statement, I removed line 299 where it assigns the $field_type
variable and added this condition after line 298.
if (isset($this->settings[$field_id]['field_type']))
{
$field_type = $this->settings[$field_id]['field_type'];
}
else
{
return FALSE;
}
On publish, unfortunately the published view in the CP is the last child playa entry associated with parent entry I just published. Might need to do a function->redirect of some sort.