Commit b1ec4a9a authored by epriestley's avatar epriestley
Browse files

Add very basic conflict detection to Phriction

Summary: Ref T4768. This is extremely basic, but will stop conflicts from going silently unnoticed.

Test Plan: {F156219}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4768

Differential Revision:
parent cc9ee66e
......@@ -93,6 +93,36 @@ final class PhrictionEditController
$errors = array();
if ($request->isFormPost()) {
$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!'))
'Another user made changes to this document after you began '.
'editing it. Do you want to overwrite their changes?'))
'If you choose to overwrite their changes, you should review '.
'the document edit history to see what you overwrote, and '.
'then make another edit to merge the changes if necessary.'))
->addSubmitButton(pht('Overwrite Changes'))
$dialog->addHiddenInput('overwrite', 'true');
foreach ($request->getPassthroughRequestData() as $key => $value) {
$dialog->addHiddenInput($key, $value);
return $dialog;
$title = $request->getStr('title');
$notes = $request->getStr('description');
......@@ -192,6 +222,7 @@ final class PhrictionEditController
->addHiddenInput('slug', $document->getSlug())
->addHiddenInput('nodraft', $request->getBool('nodraft'))
->addHiddenInput('contentVersion', $content->getVersion())
id(new AphrontFormTextControl())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment