mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 04:42:40 +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',
|
'NuanceContentSource' => 'applications/nuance/contentsource/NuanceContentSource.php',
|
||||||
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
||||||
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
||||||
|
'NuanceFormItemType' => 'applications/nuance/item/NuanceFormItemType.php',
|
||||||
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
||||||
'NuanceGitHubImportCursor' => 'applications/nuance/cursor/NuanceGitHubImportCursor.php',
|
'NuanceGitHubImportCursor' => 'applications/nuance/cursor/NuanceGitHubImportCursor.php',
|
||||||
'NuanceGitHubIssuesImportCursor' => 'applications/nuance/cursor/NuanceGitHubIssuesImportCursor.php',
|
'NuanceGitHubIssuesImportCursor' => 'applications/nuance/cursor/NuanceGitHubIssuesImportCursor.php',
|
||||||
|
@ -6716,6 +6717,7 @@ phutil_register_library_map(array(
|
||||||
'NuanceContentSource' => 'PhabricatorContentSource',
|
'NuanceContentSource' => 'PhabricatorContentSource',
|
||||||
'NuanceController' => 'PhabricatorController',
|
'NuanceController' => 'PhabricatorController',
|
||||||
'NuanceDAO' => 'PhabricatorLiskDAO',
|
'NuanceDAO' => 'PhabricatorLiskDAO',
|
||||||
|
'NuanceFormItemType' => 'NuanceItemType',
|
||||||
'NuanceGitHubEventItemType' => 'NuanceItemType',
|
'NuanceGitHubEventItemType' => 'NuanceItemType',
|
||||||
'NuanceGitHubImportCursor' => 'NuanceImportCursor',
|
'NuanceGitHubImportCursor' => 'NuanceImportCursor',
|
||||||
'NuanceGitHubIssuesImportCursor' => 'NuanceGitHubImportCursor',
|
'NuanceGitHubIssuesImportCursor' => 'NuanceGitHubImportCursor',
|
||||||
|
|
|
@ -17,10 +17,9 @@ final class NuanceGitHubIssuesImportCursor
|
||||||
|
|
||||||
$container_key = null;
|
$container_key = null;
|
||||||
|
|
||||||
return NuanceItem::initializeNewItem()
|
return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE)
|
||||||
->setStatus(NuanceItem::STATUS_IMPORTING)
|
->setStatus(NuanceItem::STATUS_IMPORTING)
|
||||||
->setSourcePHID($source->getPHID())
|
->setSourcePHID($source->getPHID())
|
||||||
->setItemType(NuanceGitHubEventItemType::ITEMTYPE)
|
|
||||||
->setItemKey($item_key)
|
->setItemKey($item_key)
|
||||||
->setItemContainerKey($container_key)
|
->setItemContainerKey($container_key)
|
||||||
->setItemProperty('api.type', 'issue')
|
->setItemProperty('api.type', 'issue')
|
||||||
|
|
|
@ -36,10 +36,9 @@ final class NuanceGitHubRepositoryImportCursor
|
||||||
$container_key = "github.issue.{$issue_id}";
|
$container_key = "github.issue.{$issue_id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return NuanceItem::initializeNewItem()
|
return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE)
|
||||||
->setStatus(NuanceItem::STATUS_IMPORTING)
|
->setStatus(NuanceItem::STATUS_IMPORTING)
|
||||||
->setSourcePHID($source->getPHID())
|
->setSourcePHID($source->getPHID())
|
||||||
->setItemType(NuanceGitHubEventItemType::ITEMTYPE)
|
|
||||||
->setItemKey($item_key)
|
->setItemKey($item_key)
|
||||||
->setItemContainerKey($container_key)
|
->setItemContainerKey($container_key)
|
||||||
->setItemProperty('api.type', 'repository')
|
->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) {
|
foreach ($handles as $phid => $handle) {
|
||||||
$item = $objects[$phid];
|
$item = $objects[$phid];
|
||||||
|
|
||||||
$handle->setName($item->getItemDisplayName());
|
$handle->setName($item->getDisplayName());
|
||||||
$handle->setURI($item->getURI());
|
$handle->setURI($item->getURI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ final class NuancePhabricatorFormSourceDefinition
|
||||||
$content_source = PhabricatorContentSource::newFromRequest($request);
|
$content_source = PhabricatorContentSource::newFromRequest($request);
|
||||||
|
|
||||||
$item = $this->newItemFromProperties(
|
$item = $this->newItemFromProperties(
|
||||||
|
NuanceFormItemType::ITEMTYPE,
|
||||||
|
$viewer->getPHID(),
|
||||||
$properties,
|
$properties,
|
||||||
$content_source);
|
$content_source);
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ final class NuancePhabricatorFormSourceDefinition
|
||||||
NuanceItem $item,
|
NuanceItem $item,
|
||||||
PHUIPropertyListView $view) {
|
PHUIPropertyListView $view) {
|
||||||
|
|
||||||
$complaint = $item->getNuanceProperty('complaint');
|
$complaint = $item->getItemProperty('complaint');
|
||||||
$complaint = new PHUIRemarkupView($viewer, $complaint);
|
$complaint = new PHUIRemarkupView($viewer, $complaint);
|
||||||
$view->addSectionHeader(
|
$view->addSectionHeader(
|
||||||
pht('Complaint'), 'fa-exclamation-circle');
|
pht('Complaint'), 'fa-exclamation-circle');
|
||||||
|
|
|
@ -149,6 +149,8 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function newItemFromProperties(
|
protected function newItemFromProperties(
|
||||||
|
$item_type,
|
||||||
|
$author_phid,
|
||||||
array $properties,
|
array $properties,
|
||||||
PhabricatorContentSource $content_source) {
|
PhabricatorContentSource $content_source) {
|
||||||
|
|
||||||
|
@ -157,7 +159,7 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
$actor = PhabricatorUser::getOmnipotentUser();
|
$actor = PhabricatorUser::getOmnipotentUser();
|
||||||
$source = $this->getSource();
|
$source = $this->getSource();
|
||||||
|
|
||||||
$item = NuanceItem::initializeNewItem();
|
$item = NuanceItem::initializeNewItem($item_type);
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
|
@ -181,6 +183,7 @@ abstract class NuanceSourceDefinition extends Phobject {
|
||||||
|
|
||||||
$editor = id(new NuanceItemEditor())
|
$editor = id(new NuanceItemEditor())
|
||||||
->setActor($actor)
|
->setActor($actor)
|
||||||
|
->setActingAsPHID($author_phid)
|
||||||
->setContentSource($content_source);
|
->setContentSource($content_source);
|
||||||
|
|
||||||
$editor->applyTransactions($item, $xactions);
|
$editor->applyTransactions($item, $xactions);
|
||||||
|
|
|
@ -26,8 +26,12 @@ final class NuanceItem
|
||||||
private $source = self::ATTACHABLE;
|
private $source = self::ATTACHABLE;
|
||||||
private $implementation = 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())
|
return id(new NuanceItem())
|
||||||
|
->setItemType($item_type)
|
||||||
->setStatus(self::STATUS_OPEN);
|
->setStatus(self::STATUS_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +46,7 @@ final class NuanceItem
|
||||||
'requestorPHID' => 'phid?',
|
'requestorPHID' => 'phid?',
|
||||||
'queuePHID' => 'phid?',
|
'queuePHID' => 'phid?',
|
||||||
'itemType' => 'text64',
|
'itemType' => 'text64',
|
||||||
'itemKey' => 'text64',
|
'itemKey' => 'text64?',
|
||||||
'itemContainerKey' => 'text64?',
|
'itemContainerKey' => 'text64?',
|
||||||
'status' => 'text32',
|
'status' => 'text32',
|
||||||
'mailKey' => 'bytes20',
|
'mailKey' => 'bytes20',
|
||||||
|
|
|
@ -8,14 +8,14 @@ final class NuanceItemPropertyTransaction
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
||||||
$key = $this->getMetadataValue($property_key);
|
$key = $this->getMetadataValue($property_key);
|
||||||
return $object->getNuanceProperty($key);
|
return $object->getItemProperty($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyInternalEffects($object, $value) {
|
public function applyInternalEffects($object, $value) {
|
||||||
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
$property_key = NuanceItemTransaction::PROPERTY_KEY;
|
||||||
$key = $this->getMetadataValue($property_key);
|
$key = $this->getMetadataValue($property_key);
|
||||||
|
|
||||||
$object->setNuanceProperty($key, $value);
|
$object->setItemProperty($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
|
|
Loading…
Reference in a new issue