@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

Stop running a second symbol migration

Fixes T8697.

+5 -80
+5 -80
resources/sql/autopatches/20150504.symbolsproject.1.php
··· 1 1 <?php 2 2 3 - $table_w = new PhabricatorRepository(); 4 - $conn_w = $table_w->establishConnection('w'); 5 - 6 - // Repository and Project share a database. 7 - $conn_r = $table_w->establishConnection('r'); 8 - $projects_table = 'repository_arcanistproject'; 9 - 10 - $raw_projects_data = queryfx_all($conn_r, 'SELECT * FROM %T', $projects_table); 11 - $raw_projects_data = ipull($raw_projects_data, null, 'id'); 12 - 13 - $repository_ids = ipull($raw_projects_data, 'repositoryID'); 14 - if (!$repository_ids) { 15 - return; 16 - } 17 - 18 - $repositories = id(new PhabricatorRepositoryQuery()) 19 - ->setViewer(PhabricatorUser::getOmnipotentUser()) 20 - ->withIDs($repository_ids) 21 - ->execute(); 22 - 23 - $projects_to_repo_ids_map = ipull($raw_projects_data, 'repositoryID', 'phid'); 24 - $projects_to_repos_map = array(); 25 - foreach ($projects_to_repo_ids_map as $projectPHID => $repositoryID) { 26 - $repo = idx($repositories, $repositoryID); 27 - if ($repo) { 28 - $projects_to_repos_map[$projectPHID] = $repo->getPHID(); 29 - } 30 - } 31 - 32 - foreach ($raw_projects_data as $project_row) { 33 - $repositoryID = idx($project_row, 'repositoryID'); 34 - $repo = idx($repositories, $repositoryID); 35 - 36 - if (!$repo) { 37 - continue; 38 - } 39 - 40 - echo pht( 41 - "Migrating symbols configuration for '%s' project...\n", 42 - idx($project_row, 'name', '???')); 43 - 44 - $symbol_index_projects = $project_row['symbolIndexProjects']; 45 - $symbol_index_projects = nonempty($symbol_index_projects, '[]'); 46 - try { 47 - $symbol_index_projects = phutil_json_decode($symbol_index_projects); 48 - } catch (PhutilJSONParserException $ex) { 49 - continue; 50 - } 51 - 52 - $sources = $repo->getDetail('symbol-sources', array()); 53 - foreach ($symbol_index_projects as $index_project) { 54 - $sources[] = idx($projects_to_repos_map, $index_project); 55 - } 56 - $sources = array_filter($sources); 57 - $sources = array_unique($sources); 58 - 59 - $repo->setDetail('symbol-sources', $sources); 60 - 61 - $languages = $project_row['symbolIndexLanguages']; 62 - $languages = nonempty($languages, '[]'); 63 - try { 64 - $languages = phutil_json_decode($languages); 65 - } catch (PhutilJSONParserException $ex) { 66 - continue; 67 - } 68 - 69 - $languages = array_merge( 70 - $repo->getDetail('symbol-languages', array()), 71 - $languages); 72 - $languages = array_unique($languages); 73 - 74 - $repo->setDetail('symbol-languages', $languages); 75 - 76 - queryfx( 77 - $conn_w, 78 - 'UPDATE %T SET details = %s WHERE id = %d', 79 - $table_w->getTableName(), 80 - json_encode($repo->getDetails()), 81 - $repo->getID()); 82 - } 3 + // NOTE: This migration moved existing symbol configuration from Arcanist 4 + // Projects to Repositories. Like "20150503.repositorysymbols.2.php", it stopped 5 + // running cleanly about two months later, after Spaces were introduced. Since 6 + // this data is easy to rebuild, just stop running the migration. See T8691 and 7 + // T8697.