@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 Differential Revision SavedQueries to the new "statuses" tokenizer

Summary: Ref T2543. This migrates existing saved queries so they use the right modern values for the new tokenizer control, introduced in D18393.

Test Plan:
- Saved a query with "Abandoned" selected as the status in the old "<select />", prior to D18393.
- Upgraded to D18393, which broke the query (it no longer selected any status filter).
- Ran the migration to fix things.
- Saw the query now execute with "Abandoned" selected in the tokenizer, preseving the original behavior accurately.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2543

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

+48
+48
resources/sql/autopatches/20170811.differential.01.status.php
··· 1 + <?php 2 + 3 + // Migrate saved Differential revision queries from using a "<select />" 4 + // control with hard-coded status groups for status selection to using a 5 + // tokenizer with status functions. 6 + 7 + $table = new PhabricatorSavedQuery(); 8 + $conn = $table->establishConnection('w'); 9 + 10 + $status_map = array( 11 + 'status-open' => array('open()'), 12 + 'status-closed' => array('closed()'), 13 + 14 + 'status-accepted' => array('accepted'), 15 + 'status-needs-review' => array('needs-review'), 16 + 'status-needs-revision' => array('needs-revision'), 17 + 'status-abandoned' => array('abandoned'), 18 + ); 19 + 20 + foreach (new LiskMigrationIterator($table) as $query) { 21 + if ($query->getEngineClassName() !== 'DifferentialRevisionSearchEngine') { 22 + // This isn't a revision query. 23 + continue; 24 + } 25 + 26 + $parameters = $query->getParameters(); 27 + $status = idx($parameters, 'status'); 28 + 29 + if (!$status) { 30 + // This query didn't specify a "status" value. 31 + continue; 32 + } 33 + 34 + if (!isset($status_map[$status])) { 35 + // The "status" value is unknown, or does not correspond to a 36 + // modern "status" constraint. 37 + continue; 38 + } 39 + 40 + $parameters['statuses'] = $status_map[$status]; 41 + 42 + queryfx( 43 + $conn, 44 + 'UPDATE %T SET parameters = %s WHERE id = %d', 45 + $table->getTableName(), 46 + phutil_json_encode($parameters), 47 + $query->getID()); 48 + }