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

Migrate revision storage to modern status constants ("accepted") instead of legacy numeric values ("2")

Summary:
Ref T2543. Rewrites all the storage to use constants.

Note that transactions still use legacy values, I'll migrate and update them separately.

Test Plan:
- Ran migration.
- Browsed around, changed revision states, viewed dashboard, etc.
- Selected `DISTINCT()` and `GROUP_CONCAT()` of the `status` field in the database, saw sane/expected before and after values.
- Verified that old Conduit methods still return numeric constants for compatibility.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

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

+24 -34
+17
resources/sql/autopatches/20170811.differential.02.modernstatus.sql
··· 1 + UPDATE {$NAMESPACE}_differential.differential_revision 2 + SET status = "needs-review" WHERE status = "0"; 3 + 4 + UPDATE {$NAMESPACE}_differential.differential_revision 5 + SET status = "needs-revision" WHERE status = "1"; 6 + 7 + UPDATE {$NAMESPACE}_differential.differential_revision 8 + SET status = "accepted" WHERE status = "2"; 9 + 10 + UPDATE {$NAMESPACE}_differential.differential_revision 11 + SET status = "published" WHERE status = "3"; 12 + 13 + UPDATE {$NAMESPACE}_differential.differential_revision 14 + SET status = "abandoned" WHERE status = "4"; 15 + 16 + UPDATE {$NAMESPACE}_differential.differential_revision 17 + SET status = "changes-planned" WHERE status = "5";
-15
src/applications/differential/constants/DifferentialLegacyQuery.php
··· 31 31 return $map[$status]; 32 32 } 33 33 34 - public static function getLegacyValues(array $modern_values) { 35 - $values = array(); 36 - foreach ($modern_values as $status_constant) { 37 - $status_object = DifferentialRevisionStatus::newForStatus( 38 - $status_constant); 39 - 40 - $legacy_key = $status_object->getLegacyKey(); 41 - if ($legacy_key !== null) { 42 - $values[] = $legacy_key; 43 - } 44 - } 45 - 46 - return $values; 47 - } 48 - 49 34 private static function getMap() { 50 35 $all = array( 51 36 DifferentialRevisionStatus::NEEDS_REVIEW,
+2 -2
src/applications/differential/query/DifferentialRevisionQuery.php
··· 695 695 $where[] = qsprintf( 696 696 $conn_r, 697 697 'r.status in (%Ls)', 698 - DifferentialLegacyQuery::getLegacyValues($this->statuses)); 698 + $this->statuses); 699 699 } 700 700 701 701 if ($this->isOpen !== null) { ··· 709 709 $where[] = qsprintf( 710 710 $conn_r, 711 711 'r.status in (%Ls)', 712 - DifferentialLegacyQuery::getLegacyValues($statuses)); 712 + $statuses); 713 713 } 714 714 715 715 $where[] = $this->buildWhereClauseParts($conn_r);
+4 -15
src/applications/differential/storage/DifferentialRevision.php
··· 613 613 } 614 614 615 615 public function setModernRevisionStatus($status) { 616 - $status_object = DifferentialRevisionStatus::newForStatus($status); 617 - 618 - if ($status_object->getKey() != $status) { 619 - throw new Exception( 620 - pht( 621 - 'Trying to set revision to invalid status "%s".', 622 - $status)); 623 - } 624 - 625 - $legacy_status = $status_object->getLegacyKey(); 626 - 627 - return $this->setStatus($legacy_status); 616 + return $this->setStatus($status); 628 617 } 629 618 630 619 public function getModernRevisionStatus() { 631 - return $this->getStatusObject()->getKey(); 620 + return $this->getStatus(); 632 621 } 633 622 634 623 public function getLegacyRevisionStatus() { 635 - return $this->getStatus(); 624 + return $this->getStatusObject()->getLegacyKey(); 636 625 } 637 626 638 627 public function isClosed() { ··· 677 666 678 667 public function getStatusObject() { 679 668 $status = $this->getStatus(); 680 - return DifferentialRevisionStatus::newForLegacyStatus($status); 669 + return DifferentialRevisionStatus::newForStatus($status); 681 670 } 682 671 683 672 public function getFlag(PhabricatorUser $viewer) {
+1 -2
src/applications/differential/xaction/DifferentialRevisionStatusTransaction.php
··· 14 14 } 15 15 16 16 public function getTitle() { 17 - $new = $this->getNewValue(); 18 - $status = DifferentialRevisionStatus::newForLegacyStatus($new); 17 + $status = $this->newStatusObject(); 19 18 20 19 if ($status->isAccepted()) { 21 20 return pht('This revision is now accepted and ready to land.');