Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While improving our test, I noticed that hook_entity_insert() (and presumably the other entity hooks) don't get passed an actual flagging entity.
stdClass::__set_state(array(
'flagging_id' => '1',
'flag_name' => 'flag_hook_test_flag',
'entity_id' => '1',
'uid' => '2',
'sid' => 0,
)),
This is missing a lot of the properties a Flagging has if you load it from the database.
Comments
Comment #1
joachim CreditAttribution: joachim commentedCalling flagging_load() gets me an object with these properties:
The rdf_mapping is added by core's RDF module I presume.
Comment #2
joachim CreditAttribution: joachim commentedComment #3
joachim CreditAttribution: joachim commentedI took a look at this and found that the hooks get a proper entity. This seemed odd, as I've done nothing to fix it yet.
So I figured that the refactoring done in the parent issue had fixed it as a byproduct: WOOHOO!
Except that comparing the before and after, I don't see how.
Then I noticed this:
Spot the mistake: the hook name (the first level key in the $hook_data_variable array) changes!
So it's quite likely this was never a bug, just a mistake in the tests I was writing due to copy-pasting assertions, and I jumped to the wrong conclusion because the code that was being tested was convoluted and hard to read...
Committing a change logged to this issue that restores all the commented-out assertions.