Skip to content

[3.0] Move to dedicated Hooks table - #8808

Open
jdarwood007 wants to merge 21 commits into
SimpleMachines:release-3.0from
jdarwood007:3.0/HooksTable
Open

jdarwood007 wants to merge 21 commits into
SimpleMachines:release-3.0from
jdarwood007:3.0/HooksTable

Conversation

@jdarwood007

Copy link
Copy Markdown
Member

Sets up a dedicated hooks table for our integrations. Hooks have become very important to our code base to ensure our mod authors are able to tap into the code where needed without needing to alter the source code. As such we should build a more efficient setup for storing and maintaining those hooks.

  • Deprecates using modSettings to store integrations.
  • Deprecates integrate_ prefix to hook names
  • Adds compatibility with SMF 2.1 logic.
  • Sets up some special handling logic for handling the pre_include (and possibly others) logic.
  • Adds logic to the package manager to handle tagging all hooks registered by a mod to it to ensure removal on uninstall.

I have toyed with the idea of fully removing all integrate_ from all files. Not sure if it's relevant to this PR. But since we are now storing hooks in their table, we don't need to have the prefix. Looking for any feedback on that, I am thinking it should be done and let the IntegrationHooks logic handle restoring it for compatibility with SMF 2.1 where needed.

I need to do more testing here as this changes a lot and I have only done some basic mod tests.

Sets up a dedicated hooks table for our integrations.

Deprecates using modSettings to store integrations.
Deprecates integrate_ prefix to hook names
Adds compatibility with SMF 2.1 logic.
Comment thread Sources/IntegrationHook.php Resolved
Comment thread Sources/Config.php Resolved
@jdarwood007
jdarwood007 marked this pull request as ready for review September 20, 2025 00:47
Comment thread Sources/IntegrationHook.php Resolved
@albertlast

Copy link
Copy Markdown
Collaborator

I closed #9700 in favour of this. Comparing the two turned up a mismatch here, as of 9ab5a9b:

The schema declares the ownership column as id_package, an unsigned int defaulting to 0:

'id_package' => new Column(
name: 'id_package',
type: 'int',
unsigned: true,
not_null: true,
default: 0,
),

Everything that reads or writes it uses package_id, as a string-255:

So every hook query names a column that does not exist. The type differs too: the value passed in is $packageInfo['id'], a string such as author:modname, which an int column cannot hold. I think the column wants to be package_id, varchar(255), to match log_packages.package_id, rather than the code changing to suit the schema.

On a possible addition: this stores which package owns each hook and carries package_id into the hooks list's data, but the list does not show it yet. Showing it is what #9700 was for. An "Added By" column naming the package, sortable so one mod's hooks group together, is what an admin needs when a forum misbehaves and the list has forty entries. It could go in here, or I can do it as a small follow-up once this lands. Whichever you prefer.

# Conflicts:
#	Sources/Actions/Admin/Maintenance.php
#	Sources/Config.php
#	Sources/IntegrationHook.php
#	Sources/Maintenance/Tools/Upgrade.php
@jdarwood007
jdarwood007 force-pushed the 3.0/HooksTable branch 3 times, most recently from 389b66c to 32e2938 Compare November 14, 2026 15:09
@jdarwood007
jdarwood007 force-pushed the 3.0/HooksTable branch 2 times, most recently from ec6736a to 62bdfe9 Compare November 14, 2026 15:18
Autoloader fixes
ErrorhandlerService fixes
@jdarwood007

Copy link
Copy Markdown
Member Author

@albertlast I don't understand what it is complaining about here.
I can reinstall the forum anywhich way and it is fine. I can add hooks, both perm and temp and they all work fine.
Yet the tests say something is broken.

@jdarwood007

Copy link
Copy Markdown
Member Author

Soon as I got phpunit to spit out some debug data...
Doesn't take away from the fact that I have to parse the unit test logs to see what failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants