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