Page MenuHomePhabricator

D18927.diff
No OneTemporary

D18927.diff

diff --git a/resources/sql/autopatches/20180124.herald.01.repetition.sql b/resources/sql/autopatches/20180124.herald.01.repetition.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180124.herald.01.repetition.sql
@@ -0,0 +1,22 @@
+/* This column was previously "uint32?" with these values:
+
+ 1: run every time
+ 0: run only the first time
+
+*/
+
+ALTER TABLE {$NAMESPACE}_herald.herald_rule
+ CHANGE repetitionPolicy
+ repetitionPolicy VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+
+/* If the old value was "0", the new value is "first". */
+
+UPDATE {$NAMESPACE}_herald.herald_rule
+ SET repetitionPolicy = 'first'
+ WHERE repetitionPolicy = '0';
+
+/* If the old value was anything else, the new value is "every". */
+
+UPDATE {$NAMESPACE}_herald.herald_rule
+ SET repetitionPolicy = 'every'
+ WHERE repetitionPolicy NOT IN ('first', '0');
diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php
--- a/src/applications/herald/storage/HeraldRule.php
+++ b/src/applications/herald/storage/HeraldRule.php
@@ -41,13 +41,10 @@
'contentType' => 'text255',
'mustMatchAll' => 'bool',
'configVersion' => 'uint32',
+ 'repetitionPolicy' => 'text32',
'ruleType' => 'text32',
'isDisabled' => 'uint32',
'triggerObjectPHID' => 'phid?',
-
- // T6203/NULLABILITY
- // This should not be nullable.
- 'repetitionPolicy' => 'uint32?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_name' => array(
@@ -261,27 +258,11 @@
public function getRepetitionPolicyStringConstant() {
- $map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.string', 'key.int');
-
- return idx($map, $this->getRepetitionPolicyIntegerConstant());
- }
-
- public function getRepetitionPolicyIntegerConstant() {
- $map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.int', 'key.int');
- $int = $this->getRepetitionPolicy();
-
- if (!isset($map[$int])) {
- return head_key($map);
- }
-
- return $int;
+ return $this->getRepetitionPolicy();
}
public function setRepetitionPolicyStringConstant($value) {
$map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.int', 'key.string');
if (!isset($map[$value])) {
throw new Exception(
@@ -290,9 +271,7 @@
$value));
}
- $int = $map[$value];
-
- return $this->setRepetitionPolicy($int);
+ return $this->setRepetitionPolicy($value);
}
public function isRepeatEvery() {
@@ -305,20 +284,15 @@
public static function getRepetitionPolicySelectOptionMap() {
$map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'select', 'key.string');
- return $map;
+ return ipull($map, 'select');
}
private static function getRepetitionPolicyMap() {
return array(
self::REPEAT_EVERY => array(
- 'key.int' => 1,
- 'key.string' => self::REPEAT_EVERY,
'select' => pht('every time'),
),
self::REPEAT_FIRST => array(
- 'key.int' => 0,
- 'key.string' => self::REPEAT_FIRST,
'select' => pht('only the first time'),
),
);

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 17, 12:18 PM (1 w, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7703533
Default Alt Text
D18927.diff (3 KB)

Event Timeline