mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Fix a handful of Nuance fatals
Summary: Ref T12738. Some of the Nuance "form" workflows currently fatal after work on the GitHub stuff. Try to make everything stop fataling, at least. Test Plan: Using "Complaints Form" no longer fatals, and now lodges a complaint instead. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12738 Differential Revision: https://secure.phabricator.com/D18007
This commit is contained in:
parent
c4392ba067
commit
272a5d668f
10 changed files with 38 additions and 11 deletions
2
resources/sql/autopatches/20170522.nuance.01.itemkey.sql
Normal file
2
resources/sql/autopatches/20170522.nuance.01.itemkey.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_nuance.nuance_item
|
||||
MODIFY itemKey VARCHAR(64) COLLATE {$COLLATE_TEXT};
|
|
@ -1606,6 +1606,7 @@ phutil_register_library_map(array(
|
|||
'NuanceContentSource' => 'applications/nuance/contentsource/NuanceContentSource.php',
|
||||
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
||||
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
||||
'NuanceFormItemType' => 'applications/nuance/item/NuanceFormItemType.php',
|
||||
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
||||
'NuanceGitHubImportCursor' => 'applications/nuance/cursor/NuanceGitHubImportCursor.php',
|
||||
'NuanceGitHubIssuesImportCursor' => 'applications/nuance/cursor/NuanceGitHubIssuesImportCursor.php',
|
||||
|
@ -6716,6 +6717,7 @@ phutil_register_library_map(array(
|
|||
'NuanceContentSource' => 'PhabricatorContentSource',
|
||||
'NuanceController' => 'PhabricatorController',
|
||||
'NuanceDAO' => 'PhabricatorLiskDAO',
|
||||
'NuanceFormItemType' => 'NuanceItemType',
|
||||
'NuanceGitHubEventItemType' => 'NuanceItemType',
|
||||
'NuanceGitHubImportCursor' => 'NuanceImportCursor',
|
||||
'NuanceGitHubIssuesImportCursor' => 'NuanceGitHubImportCursor',
|
||||
|
|
|
@ -17,10 +17,9 @@ final class NuanceGitHubIssuesImportCursor
|
|||
|
||||
$container_key = null;
|
||||
|
||||
return NuanceItem::initializeNewItem()
|
||||
return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE)
|
||||
->setStatus(NuanceItem::STATUS_IMPORTING)
|
||||
->setSourcePHID($source->getPHID())
|
||||
->setItemType(NuanceGitHubEventItemType::ITEMTYPE)
|
||||
->setItemKey($item_key)
|
||||
->setItemContainerKey($container_key)
|
||||
->setItemProperty('api.type', 'issue')
|
||||
|
|
|
@ -36,10 +36,9 @@ final class NuanceGitHubRepositoryImportCursor
|
|||
$container_key = "github.issue.{$issue_id}";
|
||||
}
|
||||
|
||||
return NuanceItem::initializeNewItem()
|
||||
return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE)
|
||||
->setStatus(NuanceItem::STATUS_IMPORTING)
|
||||
->setSourcePHID($source->getPHID())
|
||||
->setItemType(NuanceGitHubEventItemType::ITEMTYPE)
|
||||
->setItemKey($item_key)
|
||||
->setItemContainerKey($container_key)
|
||||
->setItemProperty('api.type', 'repository')
|
||||
|
|
16
src/applications/nuance/item/NuanceFormItemType.php
Normal file
16
src/applications/nuance/item/NuanceFormItemType.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
final class NuanceFormItemType
|
||||
extends NuanceItemType {
|
||||
|
||||
const ITEMTYPE = 'form.item';
|
||||
|
||||
public function getItemTypeDisplayName() {
|
||||
return pht('Form');
|
||||
}
|
||||
|
||||
public function getItemDisplayName(NuanceItem $item) {
|
||||
return pht('Complaint');
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,7 @@ final class NuanceItemPHIDType extends PhabricatorPHIDType {
|
|||
foreach ($handles as $phid => $handle) {
|
||||
$item = $objects[$phid];
|
||||
|
||||
$handle->setName($item->getItemDisplayName());
|
||||
$handle->setName($item->getDisplayName());
|
||||
$handle->setURI($item->getURI());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ final class NuancePhabricatorFormSourceDefinition
|
|||
$content_source = PhabricatorContentSource::newFromRequest($request);
|
||||
|
||||
$item = $this->newItemFromProperties(
|
||||
NuanceFormItemType::ITEMTYPE,
|
||||
$viewer->getPHID(),
|
||||
$properties,
|
||||
$content_source);
|
||||
|
||||
|
@ -79,7 +81,7 @@ final class NuancePhabricatorFormSourceDefinition
|
|||
NuanceItem $item,
|
||||
PHUIPropertyListView $view) {
|
||||
|
||||
$complaint = $item->getNuanceProperty('complaint');
|
||||
$complaint = $item->getItemProperty('complaint');
|
||||
$complaint = new PHUIRemarkupView($viewer, $complaint);
|
||||
$view->addSectionHeader(
|
||||
pht('Complaint'), 'fa-exclamation-circle');
|
||||
|
|
|
@ -149,6 +149,8 @@ abstract class NuanceSourceDefinition extends Phobject {
|
|||
}
|
||||
|
||||
protected function newItemFromProperties(
|
||||
$item_type,
|
||||
$author_phid,
|
||||
array $properties,
|
||||
PhabricatorContentSource $content_source) {
|
||||
|
||||
|
@ -157,7 +159,7 @@ abstract class NuanceSourceDefinition extends Phobject {
|
|||
$actor = PhabricatorUser::getOmnipotentUser();
|
||||
$source = $this->getSource();
|
||||
|
||||
$item = NuanceItem::initializeNewItem();
|
||||
$item = NuanceItem::initializeNewItem($item_type);
|
||||
|
||||
$xactions = array();
|
||||
|
||||
|
@ -181,6 +183,7 @@ abstract class NuanceSourceDefinition extends Phobject {
|
|||
|
||||
$editor = id(new NuanceItemEditor())
|
||||
->setActor($actor)
|
||||
->setActingAsPHID($author_phid)
|
||||
->setContentSource($content_source);
|
||||
|
||||
$editor->applyTransactions($item, $xactions);
|
||||
|
|
|
@ -26,8 +26,12 @@ final class NuanceItem
|
|||
private $source = self::ATTACHABLE;
|
||||
private $implementation = self::ATTACHABLE;
|
||||
|
||||
public static function initializeNewItem() {
|
||||
public static function initializeNewItem($item_type) {
|
||||
|
||||
// TODO: Validate that the type is valid, and construct and attach it.
|
||||
|
||||
return id(new NuanceItem())
|
||||
->setItemType($item_type)
|
||||
->setStatus(self::STATUS_OPEN);
|
||||
}
|
||||
|
||||
|
@ -42,7 +46,7 @@ final class NuanceItem
|
|||
'requestorPHID' => 'phid?',
|
||||
'queuePHID' => 'phid?',
|
||||
'itemType' => 'text64',
|
||||
'itemKey' => 'text64',
|
||||
'itemKey' => 'text64?',
|
||||
'itemContainerKey' => 'text64?',
|
||||
'status' => 'text32',
|
||||
'mailKey' => 'bytes20',
|
||||
|
|
|
@ -8,14 +8,14 @@ final class NuanceItemPropertyTransaction
|
|||
public function generateOldValue($object) {
|
||||
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
||||
$key = $this->getMetadataValue($property_key);
|
||||
return $object->getNuanceProperty($key);
|
||||
return $object->getItemProperty($key);
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
||||
$key = $this->getMetadataValue($property_key);
|
||||
|
||||
$object->setNuanceProperty($key, $value);
|
||||
$object->setItemProperty($key, $value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
|
|
Loading…
Reference in a new issue