Skip to content

Conversation

@zak39
Copy link
Contributor

@zak39 zak39 commented Aug 20, 2025

  • Resolves: #

Summary

Hi, as an app developer, when I generate a link to a user profile, my button redirects me to the instance root instead of the user profile.
To fix this issue, we need to pass core.ProfilePage in lowercase.

Please, if you merge this PR, could you also backport it to stable31?

TODO

  • ...

Checklist

@zak39 zak39 self-assigned this Aug 20, 2025
@zak39 zak39 requested a review from a team as a code owner August 20, 2025 09:50
@zak39 zak39 added the php Pull requests that update Php code label Aug 20, 2025
@zak39 zak39 requested review from Altahrim, nfebe, provokateurin and skjnldsv and removed request for a team, Altahrim, nfebe and provokateurin August 20, 2025 09:50
Signed-off-by: zak39 <fotia.baptiste@hotmail.com>
@provokateurin
Copy link
Member

The matching should be case-insensitive (as there have been ugly problems before).

}
if ($routeName === 'core.ProfilePage.index') {
return 'profile.ProfilePage.index';
if ($routeName === 'core.profilepage.index') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for legacy reasons all apps - if needed - should use the profile.ProfilePage.index name.
As it was always named core.ProfilePage.index and just then migrated to the profile app.

The naming follows our long standing naming schema: appid.TheController.methodName.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. But what if our application works through NC 28 to NC 32 ? This "legacy" function seems better to use rather than "if NCVersion>=31"...

Anyway, as fixLegacyRootName is called just after a "strtolower" on $routeName, this test never works right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, that's why we need this fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if NCVersion>=31

Cleaner way is linktoroute and a check if the returned string is empty.

Then fallback to core.profilepage.index

public function linkToRoute(string $routeName, array $arguments = []): string {
return $this->router->generate($routeName, $arguments);
}

This comment was marked as resolved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? The test in fixLegacyRootName does not work right now, because the route is lowercased before it is called. It's up to this function to compare it in a correct lowercase. (That's the purpose of the PR)

Copy link

@smarinier smarinier Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public function generate($name,
	$parameters = [],
	$absolute = false) {
	$referenceType = UrlGenerator::ABSOLUTE_URL;
	if ($absolute === false) {
		$referenceType = UrlGenerator::ABSOLUTE_PATH;
	}
	/*
	 * The route name has to be lowercase, for symfony to match it correctly.
	 * This is required because smyfony allows mixed casing for controller names in the routes.
	 * To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
	 * This is also safe on the PHP side because class and method names collide regardless of the casing.
	 */
	$name = strtolower($name);
	$name = $this->fixLegacyRootName($name);

@susnux susnux added the 3. to review Waiting for reviews label Aug 20, 2025
@susnux susnux added this to the Nextcloud 32 milestone Aug 20, 2025
@susnux susnux requested a review from come-nc August 20, 2025 14:27
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from usage this is correct

@provokateurin provokateurin merged commit f7cdb22 into master Aug 20, 2025
202 of 206 checks passed
@provokateurin provokateurin deleted the fix/lowercase-profile-page-route-name branch August 20, 2025 15:07
@welcome
Copy link

welcome bot commented Aug 20, 2025

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@zak39
Copy link
Contributor Author

zak39 commented Aug 20, 2025

Thanks for merging this PR :)

Could you please backport it to the stable 31 branch?

@susnux
Copy link
Contributor

susnux commented Aug 20, 2025

You can do this as well ;)

@susnux
Copy link
Contributor

susnux commented Aug 20, 2025

/backport to stable31

@susnux
Copy link
Contributor

susnux commented Aug 20, 2025

/backport to stable30 please

@backportbot
Copy link

backportbot bot commented Aug 20, 2025

The backport to stable30 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable30
git pull origin stable30

# Create the new backport branch
git checkout -b backport/54530/stable30

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick a98ba27a

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/54530/stable30

Error: Failed to check for changes with origin/stable30: No changes found in backport branch


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@nextcloud-bot nextcloud-bot mentioned this pull request Aug 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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

Labels

3. to review Waiting for reviews feedback-requested php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants