Bug #23565 See Comments

Getting entry in after_channel_entry_save hook from DB gives old values for new fields

Version: 4.1.3 Reporter: Low

For Low Search, I use the after_channel_entry_save hook to keep the search index up to date. For this, I use a method (that I use in multiple places) that takes an entry ID, retrieves the entry and updates the index accordingly. I use ee('Model')->get('ChannelEntry')... to get the entry.

In this particular hook, I get the new values for any field that is either native (like title) or ‘old’ (ie. pre EE4, still residing in exp_channel_data). But for ‘new’ fields, so fields having their own table, I get the old value and the new value isn’t actually updated in the DB yet. The ChannelEntry model object I get from EE therefore has mixed old and new values.

In this particular case, I can’t use the model that’s been passed through as an argument in the after_channel_entry_save hook, because I’m using the reusable method described above.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases