@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.

Add a test to verify that all routing maps are plausibly valid, and remove some dead routes

Summary:
Previously, see D20999. See also <https://discourse.phabricator-community.org/t/the-phutil-library-phutil-has-not-been-loaded/3543/>.

There are a couple of dead "Config" routes after recent changes. Add test coverage to make sure routes all point somewhere valid, then remove all the dead routes that turned up.

Test Plan: Ran tests, saw failures. Removed dead routes, got clean tests.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

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

+88 -33
+2
src/__phutil_library_map__.php
··· 275 275 'AphrontResponse' => 'aphront/response/AphrontResponse.php', 276 276 'AphrontResponseProducerInterface' => 'aphront/interface/AphrontResponseProducerInterface.php', 277 277 'AphrontRoutingMap' => 'aphront/site/AphrontRoutingMap.php', 278 + 'AphrontRoutingMapTestCase' => 'aphront/__tests__/AphrontRoutingMapTestCase.php', 278 279 'AphrontRoutingResult' => 'aphront/site/AphrontRoutingResult.php', 279 280 'AphrontSchemaQueryException' => 'infrastructure/storage/exception/AphrontSchemaQueryException.php', 280 281 'AphrontScopedUnguardedWriteCapability' => 'aphront/writeguard/AphrontScopedUnguardedWriteCapability.php', ··· 6283 6284 'AphrontRequestTestCase' => 'PhabricatorTestCase', 6284 6285 'AphrontResponse' => 'Phobject', 6285 6286 'AphrontRoutingMap' => 'Phobject', 6287 + 'AphrontRoutingMapTestCase' => 'PhabricatorTestCase', 6286 6288 'AphrontRoutingResult' => 'Phobject', 6287 6289 'AphrontSchemaQueryException' => 'AphrontQueryException', 6288 6290 'AphrontScopedUnguardedWriteCapability' => 'Phobject',
+85
src/aphront/__tests__/AphrontRoutingMapTestCase.php
··· 1 + <?php 2 + 3 + final class AphrontRoutingMapTestCase 4 + extends PhabricatorTestCase { 5 + 6 + public function testRoutingMaps() { 7 + $count = 0; 8 + 9 + $sites = AphrontSite::getAllSites(); 10 + foreach ($sites as $site) { 11 + $maps = $site->getRoutingMaps(); 12 + foreach ($maps as $map) { 13 + foreach ($map->getRoutes() as $rule => $value) { 14 + $this->assertRoutable($site, $map, array(), $rule, $value); 15 + $count++; 16 + } 17 + } 18 + } 19 + 20 + if (!$count) { 21 + $this->assertSkipped( 22 + pht('No sites define any routing rules.')); 23 + } 24 + } 25 + 26 + private function assertRoutable( 27 + AphrontSite $site, 28 + AphrontRoutingMap $map, 29 + array $path, 30 + $rule, 31 + $value) { 32 + 33 + $path[] = $rule; 34 + 35 + $site_description = $site->getDescription(); 36 + $rule_path = implode(' > ', $path); 37 + 38 + $pattern = implode('', $path); 39 + $pattern = '('.$pattern.')'; 40 + $ok = @preg_match($pattern, ''); 41 + 42 + $this->assertTrue( 43 + ($ok !== false), 44 + pht( 45 + 'Routing rule ("%s", for site "%s") does not compile into a '. 46 + 'valid regular expression.', 47 + $rule_path, 48 + $site_description)); 49 + 50 + if (is_array($value)) { 51 + $this->assertTrue( 52 + (count($value) > 0), 53 + pht( 54 + 'Routing rule ("%s", for site "%s") does not have any targets.', 55 + $rule_path, 56 + $site_description)); 57 + 58 + foreach ($value as $sub_rule => $sub_value) { 59 + $this->assertRoutable($site, $map, $path, $sub_rule, $sub_value); 60 + } 61 + return; 62 + } 63 + 64 + if (is_string($value)) { 65 + $this->assertTrue( 66 + class_exists($value), 67 + pht( 68 + 'Routing rule ("%s", for site "%s") points at controller ("%s") '. 69 + 'which does not exist.', 70 + $rule_path, 71 + $site_description, 72 + $value)); 73 + return; 74 + } 75 + 76 + $this->assertFailure( 77 + pht( 78 + 'Routing rule ("%s", for site "%s") points at unknown value '. 79 + '(of type "%s"), expected a controller class name string.', 80 + $rule_path, 81 + $site_description, 82 + phutil_describe_type($value))); 83 + } 84 + 85 + }
-4
src/applications/config/application/PhabricatorConfigApplication.php
··· 38 38 return array( 39 39 '/config/' => array( 40 40 '' => 'PhabricatorConfigConsoleController', 41 - 'application/' => 'PhabricatorConfigApplicationController', 42 - 'all/' => 'PhabricatorConfigAllController', 43 - 'history/' => 'PhabricatorConfigHistoryController', 44 41 'edit/(?P<key>[\w\.\-]+)/' => 'PhabricatorConfigEditController', 45 - 'group/(?P<key>[^/]+)/' => 'PhabricatorConfigGroupController', 46 42 'database/'. 47 43 '(?:(?P<ref>[^/]+)/'. 48 44 '(?:(?P<database>[^/]+)/'.
-2
src/applications/countdown/application/PhabricatorCountdownApplication.php
··· 42 42 '/countdown/' => array( 43 43 '(?:query/(?P<queryKey>[^/]+)/)?' 44 44 => 'PhabricatorCountdownListController', 45 - 'comment/(?P<id>[1-9]\d*)/' 46 - => 'PhabricatorCountdownCommentController', 47 45 $this->getEditRoutePattern('edit/') 48 46 => 'PhabricatorCountdownEditController', 49 47 ),
-4
src/applications/differential/application/PhabricatorDifferentialApplication.php
··· 76 76 => 'DifferentialRevisionInlinesController', 77 77 ), 78 78 'comment/' => array( 79 - 'preview/(?P<id>[1-9]\d*)/' => 'DifferentialCommentPreviewController', 80 - 'save/(?P<id>[1-9]\d*)/' => 'DifferentialCommentSaveController', 81 79 'inline/' => array( 82 - 'preview/(?P<id>[1-9]\d*)/' 83 - => 'DifferentialInlineCommentPreviewController', 84 80 'edit/(?P<id>[1-9]\d*)/' 85 81 => 'DifferentialInlineCommentEditController', 86 82 ),
-1
src/applications/files/application/PhabricatorFilesApplication.php
··· 81 81 'upload/' => 'PhabricatorFileUploadController', 82 82 'dropupload/' => 'PhabricatorFileDropUploadController', 83 83 'compose/' => 'PhabricatorFileComposeController', 84 - 'comment/(?P<id>[1-9]\d*)/' => 'PhabricatorFileCommentController', 85 84 'thread/(?P<phid>[^/]+)/' => 'PhabricatorFileLightboxController', 86 85 'delete/(?P<id>[1-9]\d*)/' => 'PhabricatorFileDeleteController', 87 86 $this->getEditRoutePattern('edit/')
-1
src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php
··· 81 81 $this->getQueryRoutePattern() => 'HarbormasterPlanListController', 82 82 $this->getEditRoutePattern('edit/') 83 83 => 'HarbormasterPlanEditController', 84 - 'order/(?:(?P<id>\d+)/)?' => 'HarbormasterPlanOrderController', 85 84 'disable/(?P<id>\d+)/' => 'HarbormasterPlanDisableController', 86 85 'behavior/(?P<id>\d+)/(?P<behaviorKey>[^/]+)/' => 87 86 'HarbormasterPlanBehaviorController',
-2
src/applications/people/application/PhabricatorPeopleApplication.php
··· 81 81 ), 82 82 '/p/(?P<username>[\w._-]+)/' => array( 83 83 '' => 'PhabricatorPeopleProfileViewController', 84 - 'item/' => $this->getProfileMenuRouting( 85 - 'PhabricatorPeopleProfileMenuController'), 86 84 ), 87 85 ); 88 86 }
+1 -15
src/applications/phame/application/PhabricatorPhameApplication.php
··· 49 49 'view/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController', 50 50 '(?P<action>publish|unpublish)/(?P<id>\d+)/' 51 51 => 'PhamePostPublishController', 52 - 'preview/(?P<id>\d+)/' => 'PhamePostPreviewController', 53 52 'preview/' => 'PhabricatorMarkupPreviewController', 54 53 'move/(?P<id>\d+)/' => 'PhamePostMoveController', 55 54 'archive/(?P<id>\d+)/' => 'PhamePostArchiveController', ··· 66 65 'picture/(?P<id>[1-9]\d*)/' => 'PhameBlogProfilePictureController', 67 66 'header/(?P<id>[1-9]\d*)/' => 'PhameBlogHeaderPictureController', 68 67 ), 69 - ) + $this->getResourceSubroutes(), 70 - ); 71 - } 72 - 73 - public function getResourceRoutes() { 74 - return array( 75 - '/phame/' => $this->getResourceSubroutes(), 76 - ); 77 - } 78 - 79 - private function getResourceSubroutes() { 80 - return array( 81 - 'r/(?P<id>\d+)/(?P<hash>[^/]+)/(?P<name>.*)' => 82 - 'PhameResourceController', 68 + ), 83 69 ); 84 70 } 85 71
-3
src/applications/phortune/application/PhabricatorPhortuneApplication.php
··· 101 101 'product/' => array( 102 102 '' => 'PhortuneProductListController', 103 103 'view/(?P<id>\d+)/' => 'PhortuneProductViewController', 104 - 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneProductEditController', 105 104 ), 106 105 'provider/' => array( 107 - 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneProviderEditController', 108 - 'disable/(?P<id>\d+)/' => 'PhortuneProviderDisableController', 109 106 '(?P<id>\d+)/(?P<action>[^/]+)/' 110 107 => 'PhortuneProviderActionController', 111 108 ),
-1
src/applications/search/application/PhabricatorSearchApplication.php
··· 30 30 return array( 31 31 '/search/' => array( 32 32 '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorSearchController', 33 - 'index/(?P<phid>[^/]+)/' => 'PhabricatorSearchIndexController', 34 33 'hovercard/' 35 34 => 'PhabricatorSearchHovercardController', 36 35 'handle/(?P<phid>[^/]+)/'