Don't warn about conflicts when reverting Phriction documents

Summary:
Fixes T5144. This was incorrectly checking the //content// version, not the //head// version, so reverts would raise the "conflict" warning.

Also fix a couple of FontAwesome icons.

Test Plan:
  - Edited a document.
  - Reverted a document.
  - Opened two edit tabs. Edited one, tried to edit #2, got a warning.
  - Opened two revert tabs. Reverted in one, tried to revert in #2, got a warning.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5144

Differential Revision: https://secure.phabricator.com/D9249
This commit is contained in:
epriestley
2014-05-21 16:05:59 -07:00
parent 2ad501873a
commit 3c8d88deb4
2 changed files with 13 additions and 7 deletions

View File

@@ -14,10 +14,12 @@ final class PhrictionEditController
$request = $this->getRequest();
$user = $request->getUser();
$current_version = null;
if ($this->id) {
$document = id(new PhrictionDocumentQuery())
->setViewer($user)
->withIDs(array($this->id))
->needContent(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -28,6 +30,8 @@ final class PhrictionEditController
return new Aphront404Response();
}
$current_version = $document->getContent()->getVersion();
$revert = $request->getInt('revert');
if ($revert) {
$content = id(new PhrictionContent())->loadOneWhere(
@@ -38,7 +42,7 @@ final class PhrictionEditController
return new Aphront404Response();
}
} else {
$content = id(new PhrictionContent())->load($document->getContentID());
$content = $document->getContent();
}
} else {
@@ -56,6 +60,7 @@ final class PhrictionEditController
if ($document) {
$content = $document->getContent();
$current_version = $content->getVersion();
} else {
if (PhrictionDocument::isProjectSlug($slug)) {
$project = id(new PhabricatorProjectQuery())
@@ -104,7 +109,6 @@ final class PhrictionEditController
$overwrite = $request->getBool('overwrite');
if (!$overwrite) {
$edit_version = $request->getStr('contentVersion');
$current_version = $content->getVersion();
if ($edit_version != $current_version) {
$dialog = $this->newDialog()
->setTitle(pht('Edit Conflict!'))
@@ -229,7 +233,7 @@ final class PhrictionEditController
->setAction($request->getRequestURI()->getPath())
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->addHiddenInput('contentVersion', $content->getVersion())
->addHiddenInput('contentVersion', $current_version)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))