Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
For now, When deleting a entity and there are messages referenced to that message all of them will be deleted. This is not scale able when we have a lot of references. We can use the core queue API for deleting in batches.
Comments
Comment #1
amitaibuLooks good.
Lets call the variable message_use_queue. (The queue name should be message_entity_delete)
with out => without
$fields => $field_names
missing @params. Also the entity-type should be first.
Add line break.
Optional; The number ...
@return
The last ...
Comment #2
RoySegall CreditAttribution: RoySegall commentedI changed the name of $fields to $fields_info(i think this is would be more appropriate). Also the entity type is the second argument - you can see it in hook_entity_delete
Comment #3
amitaibuComment #4
amitaibuWe don't need to keep this fields' info -- enough to keep the field name, and when needed field_info_field() to get the relevant data.
(so you can change the variable to $field_names after all).
Comment #5
RoySegall CreditAttribution: RoySegall commentedApply changes.
Comment #7
amitaibuTests are failing. Also:
Let's change it to ($entity-type, $entity). The fact its ike this in hook_entity_delete() was fixed in D8.
$fields => $field_names
reference two is still => reference to still
Comment #8
RoySegall CreditAttribution: RoySegall commentedThe hook entity delete get first the entity object and then the entity type although the entity delete function get the entity ID and the entity type second(confusing indeed).
Any way, i make the changes(except for the order of the hook entity delete arguments).
Comment #9
RoySegall CreditAttribution: RoySegall commentedComment #11
amitaibuThis should probably 0, otherwise you might lose that one.
Is that needed?
You can remove the $end_time
Comment #12
RoySegall CreditAttribution: RoySegall commentedComment #14
amitaibuSeems there's a notice.
Comment #15
RoySegall CreditAttribution: RoySegall commentedI found the problem - i didn't store the column in the field schema and didn't store the referenced entity identifier that were deleted. I think those are important data ;)
Comment #16
RoySegall CreditAttribution: RoySegall commentedComment #17
RoySegall CreditAttribution: RoySegall commentedI'm adding another patch that prevent a minor problem but an important one: for every deleted entity a queue worker will be created no matter of there are any messages referenced to that entity.
Patch is attached.
Comment #19
RoySegall CreditAttribution: RoySegall commentedComment #21
RoySegall CreditAttribution: RoySegall commentedComment #22
amitaibuShouldn't this patch change also message_cron()?
Comment #23
amitaibuCommitted, thanks.