@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert storage for Herald repetition policy to "text32"

Summary:
Depends on D18926. Ref T6203. Ref T13048. Herald rule repetition policies are stored as integers but treated as strings in most contexts.

After D18926, the integer stuff is almost totally hidden inside `HeraldRule` and getting rid of it completely isn't too tricky.

Do so now.

Test Plan:
- Created "only the first time" and "every time" rules. Did a SELECT on their rows in the database.
- Ran migrations, got a clean bill of health from `storage adjust`.
- Did another SELECT on the rows, saw a faithful conversion to strings "every" and "first".
- Edited and reviewed rules, swapping them between "every" and "first".

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13048, T6203

Differential Revision: https://secure.phabricator.com/D18927

+26 -30
+22
resources/sql/autopatches/20180124.herald.01.repetition.sql
··· 1 + /* This column was previously "uint32?" with these values: 2 + 3 + 1: run every time 4 + 0: run only the first time 5 + 6 + */ 7 + 8 + ALTER TABLE {$NAMESPACE}_herald.herald_rule 9 + CHANGE repetitionPolicy 10 + repetitionPolicy VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT}; 11 + 12 + /* If the old value was "0", the new value is "first". */ 13 + 14 + UPDATE {$NAMESPACE}_herald.herald_rule 15 + SET repetitionPolicy = 'first' 16 + WHERE repetitionPolicy = '0'; 17 + 18 + /* If the old value was anything else, the new value is "every". */ 19 + 20 + UPDATE {$NAMESPACE}_herald.herald_rule 21 + SET repetitionPolicy = 'every' 22 + WHERE repetitionPolicy NOT IN ('first', '0');
+4 -30
src/applications/herald/storage/HeraldRule.php
··· 41 41 'contentType' => 'text255', 42 42 'mustMatchAll' => 'bool', 43 43 'configVersion' => 'uint32', 44 + 'repetitionPolicy' => 'text32', 44 45 'ruleType' => 'text32', 45 46 'isDisabled' => 'uint32', 46 47 'triggerObjectPHID' => 'phid?', 47 - 48 - // T6203/NULLABILITY 49 - // This should not be nullable. 50 - 'repetitionPolicy' => 'uint32?', 51 48 ), 52 49 self::CONFIG_KEY_SCHEMA => array( 53 50 'key_name' => array( ··· 261 258 262 259 263 260 public function getRepetitionPolicyStringConstant() { 264 - $map = self::getRepetitionPolicyMap(); 265 - $map = ipull($map, 'key.string', 'key.int'); 266 - 267 - return idx($map, $this->getRepetitionPolicyIntegerConstant()); 268 - } 269 - 270 - public function getRepetitionPolicyIntegerConstant() { 271 - $map = self::getRepetitionPolicyMap(); 272 - $map = ipull($map, 'key.int', 'key.int'); 273 - $int = $this->getRepetitionPolicy(); 274 - 275 - if (!isset($map[$int])) { 276 - return head_key($map); 277 - } 278 - 279 - return $int; 261 + return $this->getRepetitionPolicy(); 280 262 } 281 263 282 264 public function setRepetitionPolicyStringConstant($value) { 283 265 $map = self::getRepetitionPolicyMap(); 284 - $map = ipull($map, 'key.int', 'key.string'); 285 266 286 267 if (!isset($map[$value])) { 287 268 throw new Exception( ··· 290 271 $value)); 291 272 } 292 273 293 - $int = $map[$value]; 294 - 295 - return $this->setRepetitionPolicy($int); 274 + return $this->setRepetitionPolicy($value); 296 275 } 297 276 298 277 public function isRepeatEvery() { ··· 305 284 306 285 public static function getRepetitionPolicySelectOptionMap() { 307 286 $map = self::getRepetitionPolicyMap(); 308 - $map = ipull($map, 'select', 'key.string'); 309 - return $map; 287 + return ipull($map, 'select'); 310 288 } 311 289 312 290 private static function getRepetitionPolicyMap() { 313 291 return array( 314 292 self::REPEAT_EVERY => array( 315 - 'key.int' => 1, 316 - 'key.string' => self::REPEAT_EVERY, 317 293 'select' => pht('every time'), 318 294 ), 319 295 self::REPEAT_FIRST => array( 320 - 'key.int' => 0, 321 - 'key.string' => self::REPEAT_FIRST, 322 296 'select' => pht('only the first time'), 323 297 ), 324 298 );