@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow older, invalid project tags to continue to function

Summary:
Ref T10168.

Around October 12, T9551 made project hashtags stricter and prevented them from containing characters like comma (`,`).

Around December 27, D14888 changed how hashtags queries work so that the query does normalization instead of requiring the caller to normalize.

After the Dec 27 change, projects from before Oct 12 with now-invalid hashtags will no longer load when queried directly by hashtag, because the page queries for `old,[silly]hash,,tag` or whatever, it gets normalized into `old_silly_hash_tag`, and then there are no hits.

Instead, at least for now, query by both the exact raw text and the normalized hashtag. This should keep older stuff working until we can give users more support for migrating forward.

Test Plan:
- Forced a project to have a bogus hahstag.
- Before patch: clicking its tag 404'd.
- After patch: clicking its tag now works.
- Visited a project by alternate hashtag.
- Visited a project by denormalized hashtag and alternate hashtag (e.g., capital letters instead of lowercase letters), saw it redirect/normalize properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10168

Differential Revision: https://secure.phabricator.com/D15047

+27 -9
+27 -9
src/applications/project/query/PhabricatorProjectQuery.php
··· 9 9 private $slugs; 10 10 private $slugNormals; 11 11 private $slugMap; 12 + private $allSlugs; 12 13 private $names; 13 14 private $nameTokens; 14 15 private $icons; ··· 169 170 protected function willExecute() { 170 171 $this->slugMap = array(); 171 172 $this->slugNormals = array(); 173 + $this->allSlugs = array(); 172 174 if ($this->slugs) { 173 175 foreach ($this->slugs as $slug) { 174 - $normal = PhabricatorSlug::normalizeProjectSlug($slug); 175 - $this->slugNormals[$slug] = $normal; 176 + if (PhabricatorSlug::isValidProjectSlug($slug)) { 177 + $normal = PhabricatorSlug::normalizeProjectSlug($slug); 178 + $this->slugNormals[$slug] = $normal; 179 + $this->allSlugs[$normal] = $normal; 180 + } 181 + 182 + // NOTE: At least for now, we query for the normalized slugs but also 183 + // for the slugs exactly as entered. This allows older projects with 184 + // slugs that are no longer valid to continue to work. 185 + $this->allSlugs[$slug] = $slug; 176 186 } 177 187 } 178 188 } ··· 380 390 $where[] = qsprintf( 381 391 $conn, 382 392 'slug.slug IN (%Ls)', 383 - $this->slugNormals); 393 + $this->allSlugs); 384 394 } 385 395 386 396 if ($this->names !== null) { ··· 625 635 // else. 626 636 $unknown = $this->slugNormals; 627 637 foreach ($unknown as $input => $normal) { 628 - if (!isset($primary_map[$normal])) { 638 + if (isset($primary_map[$input])) { 639 + $match = $input; 640 + } else if (isset($primary_map[$normal])) { 641 + $match = $normal; 642 + } else { 629 643 continue; 630 644 } 631 645 632 646 $this->slugMap[$input] = array( 633 - 'slug' => $normal, 634 - 'projectPHID' => $primary_map[$normal]->getPHID(), 647 + 'slug' => $match, 648 + 'projectPHID' => $primary_map[$match]->getPHID(), 635 649 ); 636 650 637 651 unset($unknown[$input]); ··· 658 672 // Link up any slugs we were not able to link up earlier. 659 673 $extra_map = mpull($slugs, 'getProjectPHID', 'getSlug'); 660 674 foreach ($unknown as $input => $normal) { 661 - if (!isset($extra_map[$normal])) { 675 + if (isset($extra_map[$input])) { 676 + $match = $input; 677 + } else if (isset($extra_map[$normal])) { 678 + $match = $normal; 679 + } else { 662 680 continue; 663 681 } 664 682 665 683 $this->slugMap[$input] = array( 666 - 'slug' => $normal, 667 - 'projectPHID' => $extra_map[$normal], 684 + 'slug' => $match, 685 + 'projectPHID' => $extra_map[$match], 668 686 ); 669 687 670 688 unset($unknown[$input]);