Repository navigation
Apply registration defaults after the account exists - #207
Merged
Merged
Conversation
With rt_page_number on, display_recent_topics() ran the topic count that sets total_topics_limit before get_forum_list(). forum_ids was still null, so get_forums_visibility_sql() reduced the count to forums where the user has m_approve: 0 for most users, and a count of only their moderated forums for a moderator, which then truncated the list and broke the pagination. Run the count after get_forum_list() and its empty-list return. The sort order is set before both, as get_allowed_topics_sql() reads it. Closes #195 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ucp_register_set_data() was subscribed to core.ucp_register_data_after, which fires while the registration form is validated, before user_add() and without a user_id. (int) $event['user_id'] was 0, so the UPDATE matched no row and new accounts kept the column defaults instead of the board's Recent Topics settings. Subscribe to core.ucp_register_register_after instead: it fires after user_add() and passes the new user_id. Closes #196 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #196.
Problem
ucp_listener::ucp_register_set_data()was subscribed tocore.ucp_register_data_after. That event fires while the registration form is validated, beforeuser_add(), and carries onlysubmit,data,cp_dataanderror.(int) $event['user_id']was therefore 0, theUPDATE … WHERE user_id = 0matched no row, and new accounts kept the column defaults instead of the board's Recent Topics settings.Fix
Subscribe the handler to
core.ucp_register_register_after, which fires afteruser_add()and passesuser_id. The handler body is unchanged. Its docblock now names the event and why.Tests
test_getSubscribedEventsnow expectscore.ucp_register_register_after.test_register_defaults_run_after_the_account_existschecks that the handler is on that event and not oncore.ucp_register_data_after. Both failed before the fix.test_ucp_register_set_datanow also checks that the query targetsWHERE user_id = 3.tests/tests.mdupdated.Checked on the local board (boot script, throwaway accounts deleted afterwards): I fired the two registration events in
ucp_register.php's order, withuser_add()in between, through a dispatcher holding only the listener under test. ACP defaults: side column, 15 topics; column defaults: top, 5.user_rt_location/user_rt_numberdevelop33RT_TOP/ 5 (column defaults, the bug)RT_SIDE/ 15 (ACP defaults)No changelog entry or version bump, per this repo's convention.
🤖 Generated with Claude Code