@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.

Update Slowvote to use sensible string constants for response visibility

Summary: Ref T13682. Migrate and update Slowvote to use API-friendly string constants for response visibility, not opaque integers.

Test Plan: Created and edited slowvotes, changing response visibility.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13682

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

+57 -8
+3
resources/sql/autopatches/20220525.slowvote.03.response-type.sql
··· 1 + ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll 2 + CHANGE responseVisibility 3 + responseVisibility VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+8
resources/sql/autopatches/20220525.slowvote.04.response-value.sql
··· 1 + UPDATE {$NAMESPACE}_slowvote.slowvote_poll 2 + SET responseVisibility = 'visible' WHERE responseVisibility = '0'; 3 + 4 + UPDATE {$NAMESPACE}_slowvote.slowvote_poll 5 + SET responseVisibility = 'voters' WHERE responseVisibility = '1'; 6 + 7 + UPDATE {$NAMESPACE}_slowvote.slowvote_poll 8 + SET responseVisibility = 'owner' WHERE responseVisibility = '2';
+23
resources/sql/autopatches/20220525.slowvote.05.response-xactions.sql
··· 1 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 2 + SET oldValue = '"visible"' WHERE 3 + transactionType = 'vote:responses' AND oldValue IN ('0', '"0"'); 4 + 5 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 6 + SET newValue = '"visible"' WHERE 7 + transactionType = 'vote:responses' AND newValue IN ('0', '"0"'); 8 + 9 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 10 + SET oldValue = '"voters"' WHERE 11 + transactionType = 'vote:responses' AND oldValue IN ('1', '"1"'); 12 + 13 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 14 + SET newValue = '"voters"' WHERE 15 + transactionType = 'vote:responses' AND newValue IN ('1', '"1"'); 16 + 17 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 18 + SET oldValue = '"owner"' WHERE 19 + transactionType = 'vote:responses' AND oldValue IN ('2', '"2"'); 20 + 21 + UPDATE {$NAMESPACE}_slowvote.slowvote_transaction 22 + SET newValue = '"owner"' WHERE 23 + transactionType = 'vote:responses' AND newValue IN ('2', '"2"');
+4 -4
src/applications/slowvote/constants/SlowvotePollResponseVisibility.php
··· 3 3 final class SlowvotePollResponseVisibility 4 4 extends Phobject { 5 5 6 - const RESPONSES_VISIBLE = 0; 7 - const RESPONSES_VOTERS = 1; 8 - const RESPONSES_OWNER = 2; 6 + const RESPONSES_VISIBLE = 'visible'; 7 + const RESPONSES_VOTERS = 'voters'; 8 + const RESPONSES_OWNER = 'owner'; 9 9 10 10 private $key; 11 11 ··· 51 51 } 52 52 53 53 private function getProperty($key, $default = null) { 54 - $spec = idx(self::getMap(), $this->getKey()); 54 + $spec = idx(self::getMap(), $this->getKey(), array()); 55 55 return idx($spec, $key, $default); 56 56 } 57 57
+11
src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php
··· 199 199 $response_type_map = SlowvotePollResponseVisibility::getAll(); 200 200 $response_type_options = mpull($response_type_map, 'getNameForEdit'); 201 201 202 + $visibility = $poll->getResponseVisibility(); 203 + if (!isset($response_type_options[$visibility])) { 204 + $visibility_object = 205 + SlowvotePollResponseVisibility::newResponseVisibilityObject( 206 + $visibility); 207 + 208 + $response_type_options = array( 209 + $visibility => $visibility_object->getNameForEdit(), 210 + ) + $response_type_options; 211 + } 212 + 202 213 if ($is_new) { 203 214 $form->appendChild( 204 215 id(new AphrontFormSelectControl())
+1 -1
src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
··· 53 53 self::CONFIG_AUX_PHID => true, 54 54 self::CONFIG_COLUMN_SCHEMA => array( 55 55 'question' => 'text255', 56 - 'responseVisibility' => 'uint32', 56 + 'responseVisibility' => 'text32', 57 57 'shuffle' => 'bool', 58 58 'method' => 'uint32', 59 59 'description' => 'text',
+2 -2
src/applications/slowvote/view/SlowvoteEmbedView.php
··· 75 75 $description, 76 76 ); 77 77 78 + $quip = pht('Voting improves cardiovascular endurance.'); 79 + 78 80 $vis = $poll->getResponseVisibility(); 79 81 if ($this->areResultsVisible()) { 80 82 if ($vis == SlowvotePollResponseVisibility::RESPONSES_OWNER) { 81 83 $quip = pht('Only you can see the results.'); 82 - } else { 83 - $quip = pht('Voting improves cardiovascular endurance.'); 84 84 } 85 85 } else if ($vis == SlowvotePollResponseVisibility::RESPONSES_VOTERS) { 86 86 $quip = pht('You must vote to see the results.');
+5 -1
src/applications/slowvote/xaction/PhabricatorSlowvoteResponsesTransaction.php
··· 6 6 const TRANSACTIONTYPE = 'vote:responses'; 7 7 8 8 public function generateOldValue($object) { 9 - return $object->getResponseVisibility(); 9 + return (string)$object->getResponseVisibility(); 10 + } 11 + 12 + public function generateNewValue($object, $value) { 13 + return (string)$value; 10 14 } 11 15 12 16 public function applyInternalEffects($object, $value) {