Just tested this because I realized this was a potential problem, and hook_schema()
does get called when uninstalling a module.
This is a problem if someone would use the Search API (or any other module using exportable entities) and later wanted to uninstall it, but would also before disable the Entity API module. The result would be a fatal error, as entity_exportable_schema_fields()
would then be missing. Therefore, even if this isn't as practical as the current solution, I think modules must directly write the field data in their schema hooks, and that should also be documented.
If you have some other suggestion for this, I'd be glad to hear it.
Comment | File | Size | Author |
---|---|---|---|
#5 | entity_schema_fields.patch | 2.33 KB | fago |
Comments
Comment #1
amitaibuI think it's the same as #1099812: Docs on how to prevent fatal error when using entity_exportable_schema_fields() from hook_update_N() -- and indeed the solution is not to use entity_exportable_schema_fields(), but to copy it.
Comment #2
drunken monkeyCopy it and replace the
ENTITY_CUSTOM
constant, now that I think about it.Even though the default value shouldn't matter while uninstalling, it still prevents a notice.
Comment #3
fagoIndeed, that's problem. I guess the helper becomes useless then :(
Comment #4
fagoComment #5
fagoPatch attached. Please review.
Note that I left the function there, so that modules making use of it right now don't suddenly break.
Comment #6
drunken monkeyLooks alright to me.
Comment #7
fagothanks, committed.
Comment #8
sunIf you don't want others to call this function, then rename it to a private function. That will not only make clear that no one should call it, but also prevent anyone from not updating potential calling code.
Powered by Dreditor.
Comment #9
fagoAs noted above:
>Note that I left the function there, so that modules making use of it right now don't suddenly break.
That way we prevent an update and dependency nightmare for user. So for now, I think it is best to stay with the name.
Comment #10
drunken monkeyI agree with Wolfgang, the function shouldn't be removed nor renamed, at least for now.
We could issue a PHP notice when the function is called, though, to bring it to the attention of developers, while leaving users (virtually) unharmed.