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

Phriction - make the check for project sub pages more fine-grained

Summary:
we were just checking if projects/ was in the URI before barfing. Use some more fun utility functions such that we only complain if there is no project.

Fixes T4071.

Test Plan: made a subpage under a project - success! tried to make a project wiki page where there was no project - successful failure! tried to make a project wiki sub page where there was no project - successful failure!

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4071

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

+32 -18
+10 -6
src/applications/phriction/controller/PhrictionDocumentController.php
··· 40 40 $document = new PhrictionDocument(); 41 41 42 42 if (PhrictionDocument::isProjectSlug($slug)) { 43 - $project = id(new PhabricatorProject())->loadOneWhere( 44 - 'phrictionSlug = %s', 45 - PhrictionDocument::getProjectSlugIdentifier($slug)); 43 + $project = id(new PhabricatorProjectQuery()) 44 + ->setViewer($user) 45 + ->withPhrictionSlugs(array( 46 + PhrictionDocument::getProjectSlugIdentifier($slug))) 47 + ->executeOne(); 46 48 if (!$project) { 47 49 return new Aphront404Response(); 48 50 } ··· 214 216 215 217 $project_phid = null; 216 218 if (PhrictionDocument::isProjectSlug($slug)) { 217 - $project = id(new PhabricatorProject())->loadOneWhere( 218 - 'phrictionSlug = %s', 219 - PhrictionDocument::getProjectSlugIdentifier($slug)); 219 + $project = id(new PhabricatorProjectQuery()) 220 + ->setViewer($viewer) 221 + ->withPhrictionSlugs(array( 222 + PhrictionDocument::getProjectSlugIdentifier($slug))) 223 + ->executeOne(); 220 224 if ($project) { 221 225 $project_phid = $project->getPHID(); 222 226 }
+5 -3
src/applications/phriction/controller/PhrictionEditController.php
··· 51 51 $content = id(new PhrictionContent())->load($document->getContentID()); 52 52 } else { 53 53 if (PhrictionDocument::isProjectSlug($slug)) { 54 - $project = id(new PhabricatorProject())->loadOneWhere( 55 - 'phrictionSlug = %s', 56 - PhrictionDocument::getProjectSlugIdentifier($slug)); 54 + $project = id(new PhabricatorProjectQuery()) 55 + ->setViewer($user) 56 + ->withPhrictionSlugs(array( 57 + PhrictionDocument::getProjectSlugIdentifier($slug))) 58 + ->executeOne(); 57 59 if (!$project) { 58 60 return new Aphront404Response(); 59 61 }
+12 -6
src/applications/phriction/controller/PhrictionNewController.php
··· 33 33 ->addSubmitButton(pht('Edit Document')); 34 34 35 35 return id(new AphrontDialogResponse())->setDialog($dialog); 36 - } elseif (substr($slug, 0, 9) == 'projects/') { 36 + } else if (PhrictionDocument::isProjectSlug($slug)) { 37 + $project = id(new PhabricatorProjectQuery()) 38 + ->setViewer($user) 39 + ->withPhrictionSlugs(array( 40 + PhrictionDocument::getProjectSlugIdentifier($slug))) 41 + ->executeOne(); 42 + if (!$project) { 37 43 $dialog = new AphrontDialogView(); 38 44 $dialog->setSubmitURI('/w/') 39 45 ->setTitle(pht('Oops!')) ··· 44 50 Create a new project with this name first.')) 45 51 ->addCancelButton('/w/', 'Okay'); 46 52 return id(new AphrontDialogResponse())->setDialog($dialog); 47 - 48 - } else { 49 - $uri = '/phriction/edit/?slug='.$slug; 50 - return id(new AphrontRedirectResponse()) 51 - ->setURI($uri); 53 + } 52 54 } 55 + 56 + $uri = '/phriction/edit/?slug='.$slug; 57 + return id(new AphrontRedirectResponse()) 58 + ->setURI($uri); 53 59 } 54 60 55 61 if ($slug == '/') {
+5 -3
src/applications/phriction/editor/PhrictionDocumentEditor.php
··· 240 240 $project_phid = null; 241 241 $slug = $document->getSlug(); 242 242 if (PhrictionDocument::isProjectSlug($slug)) { 243 - $project = id(new PhabricatorProject())->loadOneWhere( 244 - 'phrictionSlug = %s', 245 - PhrictionDocument::getProjectSlugIdentifier($slug)); 243 + $project = id(new PhabricatorProjectQuery()) 244 + ->setViewer($this->requireActor()) 245 + ->withPhrictionSlugs(array( 246 + PhrictionDocument::getProjectSlugIdentifier($slug))) 247 + ->executeOne(); 246 248 if ($project) { 247 249 $project_phid = $project->getPHID(); 248 250 }