Skip to content

[2.x] feat(core, mentions, likes): implement IdWithDisplayNameSlugDriver#4470

Open
DavideIadeluca wants to merge 5 commits intoflarum:2.xfrom
glowingblue:di/user-id-with-slug-driver
Open

[2.x] feat(core, mentions, likes): implement IdWithDisplayNameSlugDriver#4470
DavideIadeluca wants to merge 5 commits intoflarum:2.xfrom
glowingblue:di/user-id-with-slug-driver

Conversation

@DavideIadeluca
Copy link
Contributor

@DavideIadeluca DavideIadeluca commented Mar 19, 2026

Documentation PR at flarum/docs#514

Fixes #0000

Changes proposed in this pull request:
Implements a new slug driver for User. This slug driver works very similarly to the Discussion Slug driver in that that the id is used as the main mechanism for routing, but the models slug added for cosmetics.

Modifies the frontend routes extender to support adding a custom resolver class. The new UserPageResolver is needed to patch the URL in case the user has changed their username/nickname.

Example:
http://localhost/u/1-nonsense-slug-which-is-not-the-actual-user-or-nickname/likes is replaced with http://localhost/u/1-admin-username/likes

Reviewers should focus on:
Should in theory be backwards compatible. Needs a accompanying documentation PR for extension developers to start to consume the UserPageResolver when adding routes like this:

new Extend.Routes() //
    .add('user.foobar', '/u/:username/foobar', FoobarUserPage, UserPageResolver),

Screenshot

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)

@DavideIadeluca DavideIadeluca marked this pull request as ready for review March 19, 2026 13:13
@DavideIadeluca DavideIadeluca requested a review from a team as a code owner March 19, 2026 13:13
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.

1 participant