From b462a80cca31ebf55944b049a8adca4c2af997ea Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Tue, 11 Nov 2014 13:45:16 -0800 Subject: [PATCH] Phriction - kill off rest of project integration Summary: we don't need this stuff no mo'. Fixes T6506. Test Plan: cruised the wiki, noting workingess Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6506 Differential Revision: https://secure.phabricator.com/D10832 --- src/__phutil_library_map__.php | 2 - .../PhrictionDocumentController.php | 37 +------------- .../controller/PhrictionEditController.php | 11 ----- .../controller/PhrictionNewController.php | 19 -------- .../phriction/storage/PhrictionDocument.php | 20 -------- .../__tests__/PhrictionDocumentTestCase.php | 48 ------------------- 6 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d0c946c4f3..d8d58da293 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2777,7 +2777,6 @@ phutil_register_library_map(array( 'PhrictionDocumentPreviewController' => 'applications/phriction/controller/PhrictionDocumentPreviewController.php', 'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php', 'PhrictionDocumentStatus' => 'applications/phriction/constants/PhrictionDocumentStatus.php', - 'PhrictionDocumentTestCase' => 'applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php', 'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php', 'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php', 'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php', @@ -5995,7 +5994,6 @@ phutil_register_library_map(array( 'PhrictionDocumentPreviewController' => 'PhrictionController', 'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhrictionDocumentStatus' => 'PhrictionConstants', - 'PhrictionDocumentTestCase' => 'PhabricatorTestCase', 'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod', 'PhrictionEditController' => 'PhrictionController', 'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod', diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index 5c04eefaf2..61ef1ef375 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -40,17 +40,6 @@ final class PhrictionDocumentController $document = new PhrictionDocument(); - if (PhrictionDocument::isProjectSlug($slug)) { - $project = id(new PhabricatorProjectQuery()) - ->setViewer($user) - ->withPhrictionSlugs(array( - PhrictionDocument::getProjectSlugIdentifier($slug), - )) - ->executeOne(); - if (!$project) { - return new Aphront404Response(); - } - } $create_uri = '/phriction/edit/?slug='.$slug; $notice = new AphrontErrorView(); @@ -258,34 +247,10 @@ final class PhrictionDocumentController ->setUser($viewer) ->setObject($document); - $project_phid = null; - if (PhrictionDocument::isProjectSlug($slug)) { - $project = id(new PhabricatorProjectQuery()) - ->setViewer($viewer) - ->withPhrictionSlugs(array( - PhrictionDocument::getProjectSlugIdentifier($slug), - )) - ->executeOne(); - if ($project) { - $project_phid = $project->getPHID(); - } - } - - $phids = array_filter( - array( - $content->getAuthorPHID(), - $project_phid, - )); + $phids = array($content->getAuthorPHID()); $this->loadHandles($phids); - $project_info = null; - if ($project_phid) { - $view->addProperty( - pht('Project Info'), - $this->getHandle($project_phid)->renderLink()); - } - $view->addProperty( pht('Last Author'), $this->getHandle($content->getAuthorPHID())->renderLink()); diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php index 3892ab9578..8433640040 100644 --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -62,17 +62,6 @@ final class PhrictionEditController $content = $document->getContent(); $current_version = $content->getVersion(); } else { - if (PhrictionDocument::isProjectSlug($slug)) { - $project = id(new PhabricatorProjectQuery()) - ->setViewer($user) - ->withPhrictionSlugs(array( - PhrictionDocument::getProjectSlugIdentifier($slug), - )) - ->executeOne(); - if (!$project) { - return new Aphront404Response(); - } - } $document = PhrictionDocument::initializeNewDocument($user, $slug); $content = $document->getContent(); } diff --git a/src/applications/phriction/controller/PhrictionNewController.php b/src/applications/phriction/controller/PhrictionNewController.php index 333600287c..48cd5fc8f0 100644 --- a/src/applications/phriction/controller/PhrictionNewController.php +++ b/src/applications/phriction/controller/PhrictionNewController.php @@ -30,25 +30,6 @@ final class PhrictionNewController extends PhrictionController { ->addSubmitButton(pht('Edit Document')); return id(new AphrontDialogResponse())->setDialog($dialog); - } else if (PhrictionDocument::isProjectSlug($slug)) { - $project = id(new PhabricatorProjectQuery()) - ->setViewer($user) - ->withPhrictionSlugs(array( - PhrictionDocument::getProjectSlugIdentifier($slug), - )) - ->executeOne(); - if (!$project) { - $dialog = new AphrontDialogView(); - $dialog->setSubmitURI('/w/') - ->setTitle(pht('Oops!')) - ->setUser($user) - ->appendChild(pht( - 'You cannot create wiki pages under "projects/", - because they are reserved as project pages. - Create a new project with this name first.')) - ->addCancelButton('/w/', 'Okay'); - return id(new AphrontDialogResponse())->setDialog($dialog); - } } $uri = '/phriction/edit/?slug='.$slug; diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 40606fc768..41fe143e5f 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -144,26 +144,6 @@ final class PhrictionDocument extends PhrictionDAO return $this; } - public static function isProjectSlug($slug) { - $slug = PhabricatorSlug::normalize($slug); - $prefix = 'projects/'; - if ($slug == $prefix) { - // The 'projects/' document is not itself a project slug. - return false; - } - return !strncmp($slug, $prefix, strlen($prefix)); - } - - public static function getProjectSlugIdentifier($slug) { - if (!self::isProjectSlug($slug)) { - throw new Exception("Slug '{$slug}' is not a project slug!"); - } - - $slug = PhabricatorSlug::normalize($slug); - $parts = explode('/', $slug); - return $parts[1].'/'; - } - /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php b/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php deleted file mode 100644 index ede8ec3429..0000000000 --- a/src/applications/phriction/storage/__tests__/PhrictionDocumentTestCase.php +++ /dev/null @@ -1,48 +0,0 @@ - false, - 'zebra/' => false, - 'projects/' => false, - 'projects/a/' => true, - 'projects/a/b/' => true, - 'stuff/projects/a/' => false, - ); - - foreach ($slugs as $slug => $expect) { - $this->assertEqual( - $expect, - PhrictionDocument::isProjectSlug($slug), - "Is '{$slug}' a project slug?"); - } - } - - public function testProjectSlugIdentifiers() { - $slugs = array( - 'projects/' => null, - 'derp/' => null, - 'projects/a/' => 'a/', - 'projects/a/b/' => 'a/', - ); - - foreach ($slugs as $slug => $expect) { - $ex = null; - $result = null; - try { - $result = PhrictionDocument::getProjectSlugIdentifier($slug); - } catch (Exception $e) { - $ex = $e; - } - - if ($expect === null) { - $this->assertTrue((bool)$ex, "Slug '{$slug}' is invalid."); - } else { - $this->assertEqual($expect, $result, "Slug '{$slug}' identifier."); - } - } - } - -}