It looks like Rules is interfering when you have an Entity named "element". I think the name of this function should be changed since this is determined from the Entity module.
Steps to Reproduce:
1) Create an Entity named "element". (Or use https://www.drupal.org/project/element)
2) Load an element entity with Rules installed "rules_element_load"
3) Note that Entity module is trying to call "hook_ENTITY_load" and is hitting the rules module, erroring out
Since this is just a menu loader, maybe it should be prefixed with an underscore?
Thoughts? This probably won't happen too often but it would be a shame if other modules conflicted like this. Since it's not an entity in rules it probably shouldn't be calling that anyway I would think.
Workaround thanks to @davidwbarratt
function HOOK_module_implements_alter(&$implementations, $hook) {
if ($hook == 'element_load') {
unset($implementations['rules']);
}
}
Comments
Comment #1
davidwbarratt commentedComment #2
davidwbarratt commentedI discovered that the reason this is happening is because the the function `rules_element_load()` followed the pattern `hook_TYPE_load`. which is being called by DrupalDefaultEntityController::attachLoad.
Since I have an entity named "element", this causes the hook to execute, which throws an error since the arguments passed are not correct.
There is an issue to remove the hook, #1792888: Remove hook_TYPE_load call from DrupalDefaultEntityController::attachLoad(), but that request appears to have been denied.
I see three possible solutions:
Thanks!
Comment #3
davidwbarratt commentedHere's a workaround for anyone who runs into this problem:
Thanks!
Comment #4
Derimagia commentedComment #5
Derimagia commentedLooks like I made a duplicate bug for this, I'm going to update it here with some more details in the main thread.
Comment #6
tr commentedThe Element module committed a patch about a year ago which fixes this issue for Rules and for one other module (Personalize). See https://cgit.drupalcode.org/element/commit/?id=401367f3a25d915e2c2efa9b1...
That patch is very similar to the solution proposed in the original post above.
I'm closing this issue now, because this is no longer a problem.
Because Drupal hooks require magic naming in order to identify them, and because Drupal modules have a totally flat namespace, there will always be cases where function names are misidentified as hook implementations. The best way to avoid this is to avoid generic naming. 'element' is a really bad name for an entity type, because it's almost certain to conflict with other modules. Fortunately, the Element module maintainer has added that solution to prevent known conflicts.