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

at recaptime-dev/main 71 lines 2.0 kB view raw
1<?php 2 3$table = new PhabricatorRepositoryRefCursor(); 4$conn = $table->establishConnection('w'); 5 6$map = array(); 7foreach (new LiskMigrationIterator($table) as $ref) { 8 $repository_phid = $ref->getRepositoryPHID(); 9 $ref_type = $ref->getRefType(); 10 $ref_hash = $ref->getRefNameHash(); 11 12 $ref_key = "{$repository_phid}/{$ref_type}/{$ref_hash}"; 13 14 if (!isset($map[$ref_key])) { 15 $map[$ref_key] = array( 16 'id' => $ref->getID(), 17 'type' => $ref_type, 18 'hash' => $ref_hash, 19 'repositoryPHID' => $repository_phid, 20 'positions' => array(), 21 ); 22 } 23 24 // NOTE: When this migration runs, the table will have "commitIdentifier" and 25 // "isClosed" fields. Later, it won't. Since they'll be removed, we can't 26 // rely on being able to access them via the object. Instead, run a separate 27 // raw query to read them. 28 29 $row = queryfx_one( 30 $conn, 31 'SELECT commitIdentifier, isClosed FROM %T WHERE id = %d', 32 $ref->getTableName(), 33 $ref->getID()); 34 35 $map[$ref_key]['positions'][] = array( 36 'identifier' => $row['commitIdentifier'], 37 'isClosed' => (int)$row['isClosed'], 38 ); 39} 40 41// Now, write all the position rows. 42$position_table = new PhabricatorRepositoryRefPosition(); 43foreach ($map as $ref_key => $spec) { 44 $id = $spec['id']; 45 foreach ($spec['positions'] as $position) { 46 queryfx( 47 $conn, 48 'INSERT IGNORE INTO %T (cursorID, commitIdentifier, isClosed) 49 VALUES (%d, %s, %d)', 50 $position_table->getTableName(), 51 $id, 52 $position['identifier'], 53 $position['isClosed']); 54 } 55} 56 57// Finally, delete all the redundant RefCursor rows (rows with the same name) 58// so we can add proper unique keys in the next migration. 59foreach ($map as $ref_key => $spec) { 60 queryfx( 61 $conn, 62 'DELETE FROM %T WHERE refType = %s 63 AND refNameHash = %s 64 AND repositoryPHID = %s 65 AND id != %d', 66 $table->getTableName(), 67 $spec['type'], 68 $spec['hash'], 69 $spec['repositoryPHID'], 70 $spec['id']); 71}