mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +01:00
Properly version Legalpad documents
Summary: Fixes T12933. This now creates a new DocumentBody when creating or editing a legalpad document. Test Plan: Create a new document, edit document. Check database that version is saved as new row, and timestamps are correct. ```mysql> select * from legalpad_documentbody; +----+--------------------------------+--------------------------------+--------------------------------+---------+---------------+--------+-------------+--------------+ | id | phid | creatorPHID | documentPHID | version | title | text | dateCreated | dateModified | +----+--------------------------------+--------------------------------+--------------------------------+---------+---------------+--------+-------------+--------------+ | 1 | PHID-LEGB-nsgzqklzfmjahlcgobm7 | PHID-USER-72xwu7eurrpsu2kxgrvw | PHID-LEGD-v7mc3xyithjvbiqeksbj | 2 | Legal Title 1 | Body 2 | 1501037011 | 1501037081 | | 2 | PHID-LEGB-2kaytwmjusljib6pjycc | PHID-USER-72xwu7eurrpsu2kxgrvw | PHID-LEGD-v7mc3xyithjvbiqeksbj | 3 | Legal Title 1 | Body 3 | 1501037521 | 1501037521 | | 3 | PHID-LEGB-h6q6bi42w4rgxrhk3qdb | PHID-USER-72xwu7eurrpsu2kxgrvw | PHID-LEGD-7gxuhafvkoy2izkv4gdd | 1 | New 2 | asdf | 1501037553 | 1501037553 | +----+--------------------------------+--------------------------------+--------------------------------+---------+---------------+--------+-------------+--------------+ 3 rows in set (0.00 sec)``` Reviewers: epriestley Reviewed By: epriestley Subscribers: tmakarios, Korvin Maniphest Tasks: T12933 Differential Revision: https://secure.phabricator.com/D18280
This commit is contained in:
parent
ca17e2283d
commit
e7f94d7528
2 changed files with 10 additions and 3 deletions
2
resources/sql/autopatches/20170725.legalpad.date.01.sql
Normal file
2
resources/sql/autopatches/20170725.legalpad.date.01.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
UPDATE {$NAMESPACE}_legalpad.legalpad_documentbody
|
||||||
|
SET dateCreated = dateModified;
|
|
@ -45,18 +45,23 @@ final class LegalpadDocumentEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_contribution) {
|
if ($is_contribution) {
|
||||||
|
$text = $object->getDocumentBody()->getText();
|
||||||
|
$title = $object->getDocumentBody()->getTitle();
|
||||||
$object->setVersions($object->getVersions() + 1);
|
$object->setVersions($object->getVersions() + 1);
|
||||||
$body = $object->getDocumentBody();
|
|
||||||
|
$body = new LegalpadDocumentBody();
|
||||||
|
$body->setCreatorPHID($this->getActingAsPHID());
|
||||||
|
$body->setText($text);
|
||||||
|
$body->setTitle($title);
|
||||||
$body->setVersion($object->getVersions());
|
$body->setVersion($object->getVersions());
|
||||||
$body->setDocumentPHID($object->getPHID());
|
$body->setDocumentPHID($object->getPHID());
|
||||||
$body->save();
|
$body->save();
|
||||||
|
|
||||||
$object->setDocumentBodyPHID($body->getPHID());
|
$object->setDocumentBodyPHID($body->getPHID());
|
||||||
|
|
||||||
$actor = $this->getActor();
|
|
||||||
$type = PhabricatorContributedToObjectEdgeType::EDGECONST;
|
$type = PhabricatorContributedToObjectEdgeType::EDGECONST;
|
||||||
id(new PhabricatorEdgeEditor())
|
id(new PhabricatorEdgeEditor())
|
||||||
->addEdge($actor->getPHID(), $type, $object->getPHID())
|
->addEdge($this->getActingAsPHID(), $type, $object->getPHID())
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$type = PhabricatorObjectHasContributorEdgeType::EDGECONST;
|
$type = PhabricatorObjectHasContributorEdgeType::EDGECONST;
|
||||||
|
|
Loading…
Reference in a new issue