@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 80 lines 1.7 kB view raw
1<?php 2 3$phid_type = DifferentialChangesetPHIDType::TYPECONST; 4 5$changeset_table = new DifferentialChangeset(); 6 7$conn = $changeset_table->establishConnection('w'); 8$table_name = $changeset_table->getTableName(); 9 10$chunk_size = 4096; 11 12$temporary_table = 'tmp_20210215_changeset_id_map'; 13 14try { 15 queryfx( 16 $conn, 17 'CREATE TEMPORARY TABLE %T ( 18 changeset_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 19 changeset_phid VARBINARY(64) NOT NULL)', 20 $temporary_table); 21} catch (AphrontAccessDeniedQueryException $ex) { 22 throw new Exception( 23 pht( 24 'Failed to "CREATE TEMPORARY TABLE". You may need to "GRANT" the '. 25 'current MySQL user this permission.'), 26 0, 27 $ex); 28} 29 30$table_iterator = id(new LiskRawMigrationIterator($conn, $table_name)) 31 ->setPageSize($chunk_size); 32 33$chunk_iterator = new PhutilChunkedIterator($table_iterator, $chunk_size); 34foreach ($chunk_iterator as $chunk) { 35 36 $map = array(); 37 foreach ($chunk as $changeset_row) { 38 $phid = $changeset_row['phid']; 39 40 if (strlen($phid)) { 41 continue; 42 } 43 44 $phid = PhabricatorPHID::generateNewPHID($phid_type); 45 $id = $changeset_row['id']; 46 47 $map[(int)$id] = $phid; 48 } 49 50 if (!$map) { 51 continue; 52 } 53 54 $sql = array(); 55 foreach ($map as $changeset_id => $changeset_phid) { 56 $sql[] = qsprintf( 57 $conn, 58 '(%d, %s)', 59 $changeset_id, 60 $changeset_phid); 61 } 62 63 queryfx( 64 $conn, 65 'TRUNCATE TABLE %T', 66 $temporary_table); 67 68 queryfx( 69 $conn, 70 'INSERT INTO %T (changeset_id, changeset_phid) VALUES %LQ', 71 $temporary_table, 72 $sql); 73 74 queryfx( 75 $conn, 76 'UPDATE %T c JOIN %T x ON c.id = x.changeset_id 77 SET c.phid = x.changeset_phid', 78 $table_name, 79 $temporary_table); 80}