Use PhrictionDocumentQuery to load documents
Summary: Ref T4029. We use a lot of very outdated content loading in Phriction, which blocks T4029. Test Plan: - Called phriction.info - Called phriction.history - Called phriction.edit - Viewed document list. - Deleted a document. - Viewed history. - Viewed a diff. - Created a document. - Edited a document. - Moved a document. - Tried to overwrite a document with "new". - Tried to overwrite a document with "move". - Viewed a moved document note. Reviewers: btrahan Reviewed By: btrahan Subscribers: shadowhand, epriestley Maniphest Tasks: T4029 Differential Revision: https://secure.phabricator.com/D9194
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group phriction
|
||||
*/
|
||||
final class PhrictionEditController
|
||||
extends PhrictionController {
|
||||
|
||||
@@ -18,7 +15,15 @@ final class PhrictionEditController
|
||||
$user = $request->getUser();
|
||||
|
||||
if ($this->id) {
|
||||
$document = id(new PhrictionDocument())->load($this->id);
|
||||
$document = id(new PhrictionDocumentQuery())
|
||||
->setViewer($user)
|
||||
->withIDs(array($this->id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$document) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
@@ -43,12 +48,14 @@ final class PhrictionEditController
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$document = id(new PhrictionDocument())->loadOneWhere(
|
||||
'slug = %s',
|
||||
$slug);
|
||||
$document = id(new PhrictionDocumentQuery())
|
||||
->setViewer($user)
|
||||
->withSlugs(array($slug))
|
||||
->needContent(true)
|
||||
->executeOne();
|
||||
|
||||
if ($document) {
|
||||
$content = id(new PhrictionContent())->load($document->getContentID());
|
||||
$content = $document->getContent();
|
||||
} else {
|
||||
if (PhrictionDocument::isProjectSlug($slug)) {
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
|
||||
Reference in New Issue
Block a user