Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15378786
D17439.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D17439.diff
View Options
diff --git a/resources/sql/autopatches/20170301.subtype.01.col.sql b/resources/sql/autopatches/20170301.subtype.01.col.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170301.subtype.01.col.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_search.search_editengineconfiguration
+ ADD subtype VARCHAR(64) COLLATE {$COLLATE_TEXT} NOT NULL;
diff --git a/resources/sql/autopatches/20170301.subtype.02.default.sql b/resources/sql/autopatches/20170301.subtype.02.default.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170301.subtype.02.default.sql
@@ -0,0 +1,2 @@
+UPDATE {$NAMESPACE}_search.search_editengineconfiguration
+ SET subtype = 'default' WHERE subtype = '';
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2624,6 +2624,8 @@
'PhabricatorEditEngineSelectCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineSelectCommentAction.php',
'PhabricatorEditEngineSettingsPanel' => 'applications/settings/panel/PhabricatorEditEngineSettingsPanel.php',
'PhabricatorEditEngineStaticCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineStaticCommentAction.php',
+ 'PhabricatorEditEngineSubtype' => 'applications/transactions/editengine/PhabricatorEditEngineSubtype.php',
+ 'PhabricatorEditEngineSubtypeTestCase' => 'applications/transactions/editengine/__tests__/PhabricatorEditEngineSubtypeTestCase.php',
'PhabricatorEditEngineTokenizerCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineTokenizerCommentAction.php',
'PhabricatorEditField' => 'applications/transactions/editfield/PhabricatorEditField.php',
'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php',
@@ -7678,6 +7680,8 @@
'PhabricatorEditEngineSelectCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditEngineSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorEditEngineStaticCommentAction' => 'PhabricatorEditEngineCommentAction',
+ 'PhabricatorEditEngineSubtype' => 'Phobject',
+ 'PhabricatorEditEngineSubtypeTestCase' => 'PhabricatorTestCase',
'PhabricatorEditEngineTokenizerCommentAction' => 'PhabricatorEditEngineCommentAction',
'PhabricatorEditField' => 'Phobject',
'PhabricatorEditPage' => 'Phobject',
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -18,6 +18,8 @@
const EDITENGINECONFIG_DEFAULT = 'default';
+ const SUBTYPE_DEFAULT = 'default';
+
private $viewer;
private $controller;
private $isCreate;
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php b/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php
@@ -0,0 +1,36 @@
+<?php
+
+
+final class PhabricatorEditEngineSubtype
+ extends Phobject {
+
+ const SUBTYPE_DEFAULT = 'default';
+
+ public static function validateSubtypeKey($subtype) {
+ if (strlen($subtype) > 64) {
+ throw new Exception(
+ pht(
+ 'Subtype "%s" is not valid: subtype keys must be no longer than '.
+ '64 bytes.',
+ $subtype));
+ }
+
+ if (strlen($subtype) < 3) {
+ throw new Exception(
+ pht(
+ 'Subtype "%s" is not valid: subtype keys must have a minimum '.
+ 'length of 3 bytes.',
+ $subtype));
+ }
+
+ if (!preg_match('/^[a-z]+\z/', $subtype)) {
+ throw new Exception(
+ pht(
+ 'Subtype "%s" is not valid: subtype keys may only contain '.
+ 'lowercase latin letters ("a" through "z").',
+ $subtype));
+ }
+ }
+
+
+}
diff --git a/src/applications/transactions/editengine/__tests__/PhabricatorEditEngineSubtypeTestCase.php b/src/applications/transactions/editengine/__tests__/PhabricatorEditEngineSubtypeTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/editengine/__tests__/PhabricatorEditEngineSubtypeTestCase.php
@@ -0,0 +1,38 @@
+<?php
+
+final class PhabricatorEditEngineSubtypeTestCase
+ extends PhabricatorTestCase {
+
+ public function testEditEngineSubtypeKeys() {
+ $map = array(
+ // Too short.
+ 'a' => false,
+ 'ab' => false,
+
+ // Too long.
+ 'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm'.
+ 'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm' => false,
+
+ // Junk.
+ '!_(#(31 1~' => false,
+
+ // These are reasonable and valid.
+ 'default' => true,
+ 'bug' => true,
+ 'feature' => true,
+ 'risk' => true,
+ 'security' => true,
+ );
+
+ foreach ($map as $input => $expect) {
+ try {
+ PhabricatorEditEngineSubtype::validateSubtypeKey($input);
+ $actual = true;
+ } catch (Exception $ex) {
+ $actual = false;
+ }
+
+ $this->assertEqual($expect, $actual, pht('Subtype Key "%s"', $input));
+ }
+ }
+}
diff --git a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
--- a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
+++ b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
@@ -16,6 +16,7 @@
protected $isEdit = 0;
protected $createOrder = 0;
protected $editOrder = 0;
+ protected $subtype;
private $engine = self::ATTACHABLE;
@@ -32,6 +33,7 @@
PhabricatorEditEngine $engine) {
return id(new PhabricatorEditEngineConfiguration())
+ ->setSubtype(PhabricatorEditEngine::SUBTYPE_DEFAULT)
->setEngineKey($engine->getEngineKey())
->attachEngine($engine)
->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy());
@@ -84,6 +86,7 @@
'isEdit' => 'bool',
'createOrder' => 'uint32',
'editOrder' => 'uint32',
+ 'subtype' => 'text64',
),
self::CONFIG_KEY_SCHEMA => array(
'key_engine' => array(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 14, 5:01 PM (1 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7663032
Default Alt Text
D17439.diff (6 KB)
Attached To
Mode
D17439: Add a "subtype" field to EditEngine forms
Attached
Detach File
Event Timeline
Log In to Comment