[advancedcontentfilter] Fix Hook-call during install #922
No reviewers
Labels
No labels
2018.09
2019.01
2019.03
2019.06
2019.09
2019.12
2020.03
2020.06
2020.09
2020.12
2021.03
2021.07
2021.09
2022.02
2022.06
2022.09
2022.12
2023.04
2023.05
2023.09
2024.03
2024.06
2024.09
2024.12
dependencies
Hackathon 2021
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: friendica/friendica-addons#922
Loading…
Reference in a new issue
No description provided.
Delete branch "bug/7989-advancedcontfilter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes https://github.com/friendica/friendica/issues/7989
Types of hook-calls:
Hook::register()
just registers hooks, but doesn't add them to the current callHook::add()
just adds hook to the current call, but doesn't register themSince we want to call the db-definition hook just once during the install process, I switched from
Hook::register()
toHook:add()
and therefore removed the unregister call as well.I think this change is wrong. If the hook isn’t registered, the next time the DB update routine is called, the addon table won’t be added to the definition.
I’d rather the issue be fixed by calling
Hook::add
toHook::register
instead.But why do we need it here? The DB-upate routine is called directly here:
838c28f171/advancedcontentfilter/advancedcontentfilter.php (L63)
And we don't need it at other places, so why should we store this hook?
This was my first thought, but than I found this description:
cc64471e4c/src/Core/Hook.php (L67)
My interpretation is that it is intentionally not added here. And I don't know what side-effects could cause it to other hooks. So I thought better stay at one point where only one addon could get broken instead of brick the whole hook-mechanism ;-)
Imagine if we decide to delete tables absent from the definition? The addon table would be wiped out the next time the DB update routine is called.
A middle of the road approach would be to keep the register call and just add the add call.
Fair enough