Differential D17502 Diff 42112 src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function parseFieldValue($value) { | ||||
| // Otherwise, try to extract a URI value. | // Otherwise, try to extract a URI value. | ||||
| return self::parseRevisionIDFromURI($value); | return self::parseRevisionIDFromURI($value); | ||||
| } | } | ||||
| private static function parseRevisionIDFromURI($uri_string) { | private static function parseRevisionIDFromURI($uri_string) { | ||||
| $uri = new PhutilURI($uri_string); | $uri = new PhutilURI($uri_string); | ||||
| $path = $uri->getPath(); | $path = $uri->getPath(); | ||||
| if (PhabricatorEnv::isSelfURI($uri_string)) { | |||||
| $matches = null; | $matches = null; | ||||
| if (preg_match('#^/D(\d+)$#', $path, $matches)) { | if (preg_match('#^/D(\d+)$#', $path, $matches)) { | ||||
| $id = (int)$matches[1]; | return (int)$matches[1]; | ||||
| $prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/D'.$id)); | |||||
| // Make sure the URI is the same as our URI. Basically, we want to ignore | |||||
| // commits from other Phabricator installs. | |||||
| if ($uri->getDomain() == $prod_uri->getDomain()) { | |||||
| return $id; | |||||
| } | |||||
| $allowed_uris = PhabricatorEnv::getAllowedURIs('/D'.$id); | |||||
| foreach ($allowed_uris as $allowed_uri) { | |||||
| if ($uri_string == $allowed_uri) { | |||||
| return $id; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function readFieldValueFromObject(DifferentialRevision $revision) { | public function readFieldValueFromObject(DifferentialRevision $revision) { | ||||
| return $revision->getID(); | return $revision->getID(); | ||||
| Show All 22 Lines | |||||