Problem/Motivation

The auto_entitylabel_entity_insert function saves the entity and that is not allowed according to hook_entity_insert documentation https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

It breaks the hook_entity_insert and hook_entity_updates hooks for others as they now both fire in reverse order for other modules.

This hook runs once the entity has been stored. Note that hook implementations may not alter the stored entity data.

Steps to reproduce

Add hook_entity_insert and hook_entity_updates to your module and make sure you use auto_entity_label on this entity.

On entity insert hook_entity_insert and hook_entity_updates will both fire in reverse order which is wrong

Proposed resolution

Remove the save from hook_entity_insert

Remaining tasks

Remove the save from hook_entity_insert

User interface changes

API changes

Remove the save from hook_entity_insert

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

JorisTheDrupalist created an issue. See original summary.

Anybody made their first commit to this issue’s fork.

anybody’s picture

Issue summary: View changes
Status: Active » Needs review

This hook runs once the entity has been stored. Note that hook implementations may not alter the stored entity data.

Seems the whole auto_entitylabel_entity_insert() implementation makes no sense, then?
I don't really get the purpose anyway...

grevil’s picture

Status: Needs review » Needs work

I get php errors when removing this.

#3076302: Set Label runs two times on node creation already heavily modifies the method, (including removing the save call) so I guess, we should simply get that merged already. And simply close this issue.

grevil’s picture

Update: the save call is still present in #3076302: Set Label runs two times on node creation, but just moved into a helper methdo, let's keep this open and wait that issue to get resolved, afterwards we can tackle the removal here.

POSTPONED on #3076302: Set Label runs two times on node creation.

dqd’s picture

Title: auto_entitylabel_entity_insert saves the entity and that is not allowed » auto_entitylabel_entity_insert breaks hook_entity_insert
Priority: Major » Normal

@grevel: agreed. +1