Skip to content

Apply registration defaults after the account exists - #207

Merged
avandenberghe merged 3 commits into
develop33from
issue-196-register-defaults
Oct 4, 2026
Merged

avandenberghe merged 3 commits into
develop33from
issue-196-register-defaults

Conversation

@avandenberghe

Copy link
Copy Markdown
Member

Closes #196.

Problem
ucp_listener::ucp_register_set_data() was subscribed to core.ucp_register_data_after. That event fires while the registration form is validated, before user_add(), and carries only submit, data, cp_data and error. (int) $event['user_id'] was therefore 0, the UPDATE … WHERE user_id = 0 matched 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 after user_add() and passes user_id. The handler body is unchanged. Its docblock now names the event and why.

Tests

  • test_getSubscribedEvents now expects core.ucp_register_register_after.
  • New test_register_defaults_run_after_the_account_exists checks that the handler is on that event and not on core.ucp_register_data_after. Both failed before the fix.
  • test_ucp_register_set_data now also checks that the query targets WHERE user_id = 3.
  • tests/tests.md updated.
  • Unit suite: 46 tests, 0 failures, run locally. The functional tests run in CI.

Checked on the local board (boot script, throwaway accounts deleted afterwards): I fired the two registration events in ucp_register.php's order, with user_add() in between, through a dispatcher holding only the listener under test. ACP defaults: side column, 15 topics; column defaults: top, 5.

Listener New account's user_rt_location / user_rt_number
current develop33 RT_TOP / 5 (column defaults, the bug)
this PR RT_SIDE / 15 (ACP defaults)

No changelog entry or version bump, per this repo's convention.

🤖 Generated with Claude Code

avandenberghe and others added 3 commits October 4, 2026 21:51
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>
@avandenberghe
avandenberghe merged commit 95466be into develop33 Oct 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New user defaults never applied: ucp_register_set_data reads user_id from an event that doesn't provide it

1 participant