In

public function save($entity)

We have two module_invoke_all functions to

hook_entity_presave()
hook_entity_update() or hook_entity_insert()
   // Invoke hook_entity_presave().
    module_invoke_all('entity_presave', 'entity_example_basic', $entity);
     $invocation = 'entity_insert';
    // Now we need to either insert or update the fields which are
    // attached to this entity. We use the same primary_keys logic
    // to determine whether to update or insert, and which hook we
    // need to invoke.
    if (empty($primary_keys)) {
      field_attach_insert('entity_example_basic', $entity);
    }
    else {
      field_attach_update('entity_example_basic', $entity);
      $invocation = 'entity_update';
    }
    // Invoke either hook_entity_update() or hook_entity_insert().
    module_invoke_all($invocation, 'entity_example_basic', $entity);

We send the arguments: $hook, $entity_type, $entity.

And the correct arguments are: $hook, $entity, $entity_type

@link: hook_entity_presave

Regards!

CommentFileSizeAuthor
fix_module_invoke_all_arguments.patch1004 bytesfacine

Comments

mile23’s picture

Status: Active » Needs review

Thanks, facine. Let's see what the test bot says.

mile23’s picture

Status: Needs review » Fixed
facine’s picture

Thanks you.

Regards!

SlashCrew’s picture

This has course much headache here. Just found the bug, and wanted to report it, but you beat me to it. :-)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Add link