diff --git a/resources/sql/autopatches/20170725.legalpad.date.01.sql b/resources/sql/autopatches/20170725.legalpad.date.01.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20170725.legalpad.date.01.sql @@ -0,0 +1,2 @@ +UPDATE {$NAMESPACE}_legalpad.legalpad_documentbody + SET dateCreated = dateModified; diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -45,18 +45,23 @@ } if ($is_contribution) { + $text = $object->getDocumentBody()->getText(); + $title = $object->getDocumentBody()->getTitle(); $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->setDocumentPHID($object->getPHID()); $body->save(); $object->setDocumentBodyPHID($body->getPHID()); - $actor = $this->getActor(); $type = PhabricatorContributedToObjectEdgeType::EDGECONST; id(new PhabricatorEdgeEditor()) - ->addEdge($actor->getPHID(), $type, $object->getPHID()) + ->addEdge($this->getActingAsPHID(), $type, $object->getPHID()) ->save(); $type = PhabricatorObjectHasContributorEdgeType::EDGECONST;