We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Bug and workaround in api_channel_entries, submit new entry multiple times

Development and Programming

leonardteo's avatar
leonardteo
32 posts
15 years ago
leonardteo's avatar leonardteo

Hey guys,

If you’re writing a custom data importer that uses relationships, there is a ‘gotcha’ in the api_channel_entries and submitting a new entry multiple times. The relationship data gets all messed up.

The culprit is that the method _build_relationships($data) checks if there already is an $entry_id as a class member.

Once you have called submit_new_entry(), make sure to clear the entry_id:

i.e.:

if ($this->EE->api_channel_entries->submit_new_entry(4, $data) === FALSE){
   return false;
} 

$entry_id = $this->EE->api_channel_entries->entry_id;  //get the entry id for whatever you want
$this->EE->api_channel_entries->entry_id = NULL;  //FORCE CLEAR THE entry_id
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.