Page MenuHomePhabricator

D21606.diff
No OneTemporary

D21606.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4253,6 +4253,7 @@
'PhabricatorPhurlURLViewController' => 'applications/phurl/controller/PhabricatorPhurlURLViewController.php',
'PhabricatorPinnedApplicationsSetting' => 'applications/settings/setting/PhabricatorPinnedApplicationsSetting.php',
'PhabricatorPirateEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorPirateEnglishTranslation.php',
+ 'PhabricatorPlatform404Controller' => 'applications/base/controller/PhabricatorPlatform404Controller.php',
'PhabricatorPlatformSite' => 'aphront/site/PhabricatorPlatformSite.php',
'PhabricatorPointsEditField' => 'applications/transactions/editfield/PhabricatorPointsEditField.php',
'PhabricatorPointsFact' => 'applications/fact/fact/PhabricatorPointsFact.php',
@@ -4689,6 +4690,8 @@
'PhabricatorResetPasswordUserLogType' => 'applications/people/userlog/PhabricatorResetPasswordUserLogType.php',
'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php',
'PhabricatorRobotsController' => 'applications/system/controller/PhabricatorRobotsController.php',
+ 'PhabricatorRobotsPlatformController' => 'applications/system/controller/PhabricatorRobotsPlatformController.php',
+ 'PhabricatorRobotsResourceController' => 'applications/system/controller/PhabricatorRobotsResourceController.php',
'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php',
'PhabricatorSMSAuthFactor' => 'applications/auth/factor/PhabricatorSMSAuthFactor.php',
'PhabricatorSQLPatchList' => 'infrastructure/storage/patch/PhabricatorSQLPatchList.php',
@@ -10914,6 +10917,7 @@
'PhabricatorPhurlURLViewController' => 'PhabricatorPhurlController',
'PhabricatorPinnedApplicationsSetting' => 'PhabricatorInternalSetting',
'PhabricatorPirateEnglishTranslation' => 'PhutilTranslation',
+ 'PhabricatorPlatform404Controller' => 'PhabricatorController',
'PhabricatorPlatformSite' => 'PhabricatorSite',
'PhabricatorPointsEditField' => 'PhabricatorEditField',
'PhabricatorPointsFact' => 'PhabricatorFact',
@@ -11471,6 +11475,8 @@
'PhabricatorResetPasswordUserLogType' => 'PhabricatorUserLogType',
'PhabricatorResourceSite' => 'PhabricatorSite',
'PhabricatorRobotsController' => 'PhabricatorController',
+ 'PhabricatorRobotsPlatformController' => 'PhabricatorRobotsController',
+ 'PhabricatorRobotsResourceController' => 'PhabricatorRobotsController',
'PhabricatorS3FileStorageEngine' => 'PhabricatorFileStorageEngine',
'PhabricatorSMSAuthFactor' => 'PhabricatorAuthFactor',
'PhabricatorSQLPatchList' => 'Phobject',
diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php
--- a/src/aphront/configuration/AphrontApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontApplicationConfiguration.php
@@ -32,10 +32,6 @@
return $request;
}
- public function build404Controller() {
- return array(new Phabricator404Controller(), array());
- }
-
public function buildRedirectController($uri, $external) {
return array(
new PhabricatorRedirectController(),
@@ -504,7 +500,10 @@
return array($result, array());
}
- return $this->build404Controller();
+ throw new Exception(
+ pht(
+ 'Aphront site ("%s") failed to build a 404 controller.',
+ get_class($site)));
}
/**
diff --git a/src/aphront/response/Aphront404Response.php b/src/aphront/response/Aphront404Response.php
--- a/src/aphront/response/Aphront404Response.php
+++ b/src/aphront/response/Aphront404Response.php
@@ -10,10 +10,17 @@
$request = $this->getRequest();
$viewer = $request->getViewer();
+ // See T13636. Note that this response may be served from a Site other than
+ // the primary PlatformSite. For now, always link to the PlatformSite.
+
+ // (This may not be the best possible place to send users who are currently
+ // on "real" sites, like the BlogSite.)
+ $return_uri = PhabricatorEnv::getURI('/');
+
$dialog = id(new AphrontDialogView())
->setViewer($viewer)
->setTitle(pht('404 Not Found'))
- ->addCancelButton('/', pht('Return to Charted Waters'))
+ ->addCancelButton($return_uri, pht('Return to Charted Waters'))
->appendParagraph(
pht(
'You arrive at your destination, but there is nothing here.'))
diff --git a/src/aphront/site/AphrontSite.php b/src/aphront/site/AphrontSite.php
--- a/src/aphront/site/AphrontSite.php
+++ b/src/aphront/site/AphrontSite.php
@@ -10,7 +10,7 @@
abstract public function getRoutingMaps();
public function new404Controller(AphrontRequest $request) {
- return null;
+ return new Phabricator404Controller();
}
protected function isHostMatch($host, array $uris) {
diff --git a/src/aphront/site/PhabricatorPlatformSite.php b/src/aphront/site/PhabricatorPlatformSite.php
--- a/src/aphront/site/PhabricatorPlatformSite.php
+++ b/src/aphront/site/PhabricatorPlatformSite.php
@@ -50,4 +50,8 @@
return $maps;
}
+ public function new404Controller(AphrontRequest $request) {
+ return new PhabricatorPlatform404Controller();
+ }
+
}
diff --git a/src/applications/auth/extension/PhabricatorAuthMainMenuBarExtension.php b/src/applications/auth/extension/PhabricatorAuthMainMenuBarExtension.php
--- a/src/applications/auth/extension/PhabricatorAuthMainMenuBarExtension.php
+++ b/src/applications/auth/extension/PhabricatorAuthMainMenuBarExtension.php
@@ -39,7 +39,13 @@
private function buildLoginMenu() {
$controller = $this->getController();
- $uri = new PhutilURI('/auth/start/');
+ // See T13636. This button may be rendered by the 404 controller on sites
+ // other than the primary PlatformSite. Link the button to the primary
+ // site.
+
+ $uri = '/auth/start/';
+ $uri = PhabricatorEnv::getURI($uri);
+ $uri = new PhutilURI($uri);
if ($controller) {
$path = $controller->getRequest()->getPath();
$uri->replaceQueryParam('next', $path);
diff --git a/src/applications/base/controller/Phabricator404Controller.php b/src/applications/base/controller/Phabricator404Controller.php
--- a/src/applications/base/controller/Phabricator404Controller.php
+++ b/src/applications/base/controller/Phabricator404Controller.php
@@ -1,6 +1,11 @@
<?php
-final class Phabricator404Controller extends PhabricatorController {
+final class Phabricator404Controller
+ extends PhabricatorController {
+
+ public function shouldRequireLogin() {
+ return false;
+ }
public function processRequest() {
return new Aphront404Response();
diff --git a/src/applications/base/controller/Phabricator404Controller.php b/src/applications/base/controller/PhabricatorPlatform404Controller.php
copy from src/applications/base/controller/Phabricator404Controller.php
copy to src/applications/base/controller/PhabricatorPlatform404Controller.php
--- a/src/applications/base/controller/Phabricator404Controller.php
+++ b/src/applications/base/controller/PhabricatorPlatform404Controller.php
@@ -1,6 +1,7 @@
<?php
-final class Phabricator404Controller extends PhabricatorController {
+final class PhabricatorPlatform404Controller
+ extends PhabricatorController {
public function processRequest() {
return new Aphront404Response();
diff --git a/src/applications/system/application/PhabricatorSystemApplication.php b/src/applications/system/application/PhabricatorSystemApplication.php
--- a/src/applications/system/application/PhabricatorSystemApplication.php
+++ b/src/applications/system/application/PhabricatorSystemApplication.php
@@ -25,7 +25,7 @@
'/status/' => 'PhabricatorStatusController',
'/debug/' => 'PhabricatorDebugController',
'/favicon.ico' => 'PhabricatorFaviconController',
- '/robots.txt' => 'PhabricatorRobotsController',
+ '/robots.txt' => 'PhabricatorRobotsPlatformController',
'/services/' => array(
'encoding/' => 'PhabricatorSystemSelectEncodingController',
'highlight/' => 'PhabricatorSystemSelectHighlightController',
@@ -38,4 +38,12 @@
);
}
+ public function getResourceRoutes() {
+ return array(
+ '/status/' => 'PhabricatorStatusController',
+ '/favicon.ico' => 'PhabricatorFaviconController',
+ '/robots.txt' => 'PhabricatorRobotsResourceController',
+ );
+ }
+
}
diff --git a/src/applications/system/controller/PhabricatorRobotsController.php b/src/applications/system/controller/PhabricatorRobotsController.php
--- a/src/applications/system/controller/PhabricatorRobotsController.php
+++ b/src/applications/system/controller/PhabricatorRobotsController.php
@@ -1,26 +1,13 @@
<?php
-final class PhabricatorRobotsController extends PhabricatorController {
+abstract class PhabricatorRobotsController extends PhabricatorController {
public function shouldRequireLogin() {
return false;
}
- public function processRequest() {
- $out = array();
-
- // Prevent indexing of '/diffusion/', since the content is not generally
- // useful to index, web spiders get stuck scraping the history of every
- // file, and much of the content is Ajaxed in anyway so spiders won't even
- // see it. These pages are also relatively expensive to generate.
-
- // Note that this still allows commits (at '/rPxxxxx') to be indexed.
- // They're probably not hugely useful, but suffer fewer of the problems
- // Diffusion suffers and are hard to omit with 'robots.txt'.
-
- $out[] = 'User-Agent: *';
- $out[] = 'Disallow: /diffusion/';
- $out[] = 'Disallow: /source/';
+ final public function processRequest() {
+ $out = $this->newRobotsRules();
// Add a small crawl delay (number of seconds between requests) for spiders
// which respect it. The intent here is to prevent spiders from affecting
@@ -36,4 +23,7 @@
->setCacheDurationInSeconds(phutil_units('2 hours in seconds'))
->setCanCDN(true);
}
+
+ abstract protected function newRobotsRules();
+
}
diff --git a/src/applications/system/controller/PhabricatorRobotsPlatformController.php b/src/applications/system/controller/PhabricatorRobotsPlatformController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/system/controller/PhabricatorRobotsPlatformController.php
@@ -0,0 +1,25 @@
+<?php
+
+final class PhabricatorRobotsPlatformController
+ extends PhabricatorRobotsController {
+
+ protected function newRobotsRules() {
+ $out = array();
+
+ // Prevent indexing of '/diffusion/', since the content is not generally
+ // useful to index, web spiders get stuck scraping the history of every
+ // file, and much of the content is Ajaxed in anyway so spiders won't even
+ // see it. These pages are also relatively expensive to generate.
+
+ // Note that this still allows commits (at '/rPxxxxx') to be indexed.
+ // They're probably not hugely useful, but suffer fewer of the problems
+ // Diffusion suffers and are hard to omit with 'robots.txt'.
+
+ $out[] = 'User-Agent: *';
+ $out[] = 'Disallow: /diffusion/';
+ $out[] = 'Disallow: /source/';
+
+ return $out;
+ }
+
+}
diff --git a/src/applications/system/controller/PhabricatorRobotsResourceController.php b/src/applications/system/controller/PhabricatorRobotsResourceController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/system/controller/PhabricatorRobotsResourceController.php
@@ -0,0 +1,17 @@
+<?php
+
+final class PhabricatorRobotsResourceController
+ extends PhabricatorRobotsController {
+
+ protected function newRobotsRules() {
+ $out = array();
+
+ // See T13636. Prevent indexing of any content on resource domains.
+
+ $out[] = 'User-Agent: *';
+ $out[] = 'Disallow: /';
+
+ return $out;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 24, 11:38 AM (12 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7040178
Default Alt Text
D21606.diff (11 KB)

Event Timeline