1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Make PhrictionContent "description" non-nullable

Summary:
Depends on D19095. Ref T6203. Ref T13077. This column is nullable in an inconsistent way. Make it non-nullable.

Also clean up one more content query on the history view.

Test Plan: Ran migration, then created and edited documents without providing a descriptino or hitting `NULL` exceptions.

Maniphest Tasks: T13077, T6203

Differential Revision: https://secure.phabricator.com/D19096
This commit is contained in:
epriestley 2018-02-15 05:42:01 -08:00
parent f742d00c28
commit a965d8d6ae
7 changed files with 17 additions and 16 deletions

View file

@ -0,0 +1,2 @@
UPDATE {$NAMESPACE}_phriction.phriction_content
SET description = '' WHERE description IS NULL;

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phriction.phriction_content
CHANGE description description LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};

View file

@ -57,7 +57,7 @@ final class PhrictionCreateConduitAPIMethod extends PhrictionConduitAPIMethod {
->setActor($request->getUser())
->setContentSource($request->newContentSource())
->setContinueOnNoEffect(true)
->setDescription($request->getValue('description'));
->setDescription((string)$request->getValue('description'));
try {
$editor->applyTransactions($doc, $xactions);

View file

@ -52,7 +52,7 @@ final class PhrictionEditConduitAPIMethod extends PhrictionConduitAPIMethod {
->setActor($request->getUser())
->setContentSource($request->newContentSource())
->setContinueOnNoEffect(true)
->setDescription($request->getValue('description'));
->setDescription((string)$request->getValue('description'));
try {
$editor->applyTransactions($doc, $xactions);

View file

@ -22,16 +22,13 @@ final class PhrictionHistoryController
$current = $document->getContent();
$pager = new PHUIPagerView();
$pager->setOffset($request->getInt('page'));
$pager->setURI($request->getRequestURI(), 'page');
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$history = id(new PhrictionContent())->loadAllWhere(
'documentID = %d ORDER BY version DESC LIMIT %d, %d',
$document->getID(),
$pager->getOffset(),
$pager->getPageSize() + 1);
$history = $pager->sliceResults($history);
$history = id(new PhrictionContentQuery())
->setViewer($viewer)
->withDocumentPHIDs(array($document->getPHID()))
->executeWithCursorPager($pager);
$author_phids = mpull($history, 'getAuthorPHID');
$handles = $this->loadViewerHandles($author_phids);

View file

@ -596,10 +596,13 @@ final class PhrictionTransactionEditor
->setAuthorPHID($this->getActor()->getPHID())
->setChangeType(PhrictionChangeType::CHANGE_EDIT)
->setTitle($this->getOldContent()->getTitle())
->setContent($this->getOldContent()->getContent());
->setContent($this->getOldContent()->getContent())
->setDescription('');
if (strlen($this->getDescription())) {
$new_content->setDescription($this->getDescription());
}
$new_content->setVersion($this->getOldContent()->getVersion() + 1);
return $new_content;

View file

@ -30,10 +30,7 @@ final class PhrictionContent
'content' => 'text',
'changeType' => 'uint32',
'changeRef' => 'uint32?',
// T6203/NULLABILITY
// This should just be empty if not provided?
'description' => 'text?',
'description' => 'text',
),
self::CONFIG_KEY_SCHEMA => array(
'documentID' => array(