@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Do not drop the milestone slug in the URI of a 404

Summary:
Since rP70053bee and the followup fix in rP972788b8, Phorge does not generate slugs for milestones.

Users however can set an alternative slug for a milestone which can be used for typeahead autocompletion (writing `#alternative-milestone-slug` in a text field) but not to access a milestone by constructing an URI like `http://phorge.localhost/tag/alternative-milestone-slug/`.

Phorge correctly returns a 404 but also confusingly rewrites the URI to `http://phorge.localhost/tag//` as we have a valid `$slug` but our `$primary_slug` is `null`, and `$primary_uri = "/tag/{$primary_slug}/"` rewrites the URI accordingly. Instead, just keep the URI and throw an explicit 404.

Closes T15547

Test Plan: See the list of steps in T15547, look at the resulting URI.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15547

Differential Revision: https://we.phorge.it/D26124

+4
+4
src/applications/project/controller/PhabricatorProjectController.php
··· 91 91 // Redirect to the canonical slug. 92 92 $primary_slug = $project->getPrimarySlug(); 93 93 if ($slug && ($slug !== $primary_slug)) { 94 + // Things like milestones do not have a '/tag/something/' page. 95 + if (!phutil_nonempty_string($primary_slug)) { 96 + return new Aphront404Response(); 97 + } 94 98 $primary_uri = "/tag/{$primary_slug}/"; 95 99 return id(new AphrontRedirectResponse())->setURI($primary_uri); 96 100 }