Skip to content

Commit 57b898a

Browse files
author
epriestley
committed
Merge branch 'master' into redesign-2015
2 parents cbf1b1a + c075f7f commit 57b898a

File tree

452 files changed

+10717
-5209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

452 files changed

+10717
-5209
lines changed

conf/__init_conf__.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?php
22

33
function phabricator_read_config_file($original_config) {
4-
54
$root = dirname(dirname(__FILE__));
65

76
// Accept either "myconfig" (preferred) or "myconfig.conf.php".
87
$config = preg_replace('/\.conf\.php$/', '', $original_config);
98
$full_config_path = $root.'/conf/'.$config.'.conf.php';
109

1110
if (!Filesystem::pathExists($full_config_path)) {
12-
1311
// These are very old configuration files which we used to ship with
1412
// by default. File based configuration was de-emphasized once web-based
1513
// configuration was built. The actual files were removed to reduce
@@ -37,12 +35,14 @@ function phabricator_read_config_file($original_config) {
3735
$file = trim($file, './');
3836
$files[$key] = preg_replace('/\.conf\.php$/', '', $file);
3937
}
40-
$files = " ".implode("\n ", $files);
38+
$files = ' '.implode("\n ", $files);
4139

4240
throw new Exception(
43-
"CONFIGURATION ERROR\n".
44-
"Config file '{$original_config}' does not exist. Valid config files ".
45-
"are:\n\n".$files);
41+
pht(
42+
"CONFIGURATION ERROR\n".
43+
"Config file '%s' does not exist. Valid config files are:\n\n%s",
44+
$original_config,
45+
$files));
4646
}
4747

4848
// Make sure config file errors are reported.
@@ -58,7 +58,11 @@ function phabricator_read_config_file($original_config) {
5858
ini_set('display_errors', $old_display_errors);
5959

6060
if ($conf === false) {
61-
throw new Exception("Failed to read config file '{$config}': {$errors}");
61+
throw new Exception(
62+
pht(
63+
"Failed to read config file '%s': %s",
64+
$config,
65+
$errors));
6266
}
6367

6468
return $conf;
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
<?php
22

3-
$projects = id(new PhabricatorRepositoryArcanistProjectQuery())
4-
->setViewer(PhabricatorUser::getOmnipotentUser())
5-
->needRepositories(true)
6-
->execute();
7-
83
$table = new PhabricatorRepositorySymbol();
94
$conn_w = $table->establishConnection('w');
105

6+
$projects = queryfx_all(
7+
$conn_w,
8+
'SELECT * FROM %T',
9+
'repository_arcanistproject');
10+
1111
foreach ($projects as $project) {
12-
$repo = $project->getRepository();
12+
$repo = id(new PhabricatorRepositoryQuery())
13+
->setViewer(PhabricatorUser::getOmnipotentUser())
14+
->withIDs(array($project['repositoryID']))
15+
->executeOne();
1316

1417
if (!$repo) {
1518
continue;
1619
}
1720

18-
echo pht("Migrating symbols for '%s' project...\n", $project->getName());
21+
echo pht("Migrating symbols for '%s' project...\n", $project['name']);
1922

2023
queryfx(
2124
$conn_w,
2225
'UPDATE %T SET repositoryPHID = %s WHERE arcanistProjectID = %d',
2326
$table->getTableName(),
2427
$repo->getPHID(),
25-
$project->getID());
28+
$project['id']);
2629
}

resources/sql/autopatches/20150504.symbolsproject.1.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
$raw_projects_data = ipull($raw_projects_data, null, 'id');
1212

1313
$repository_ids = ipull($raw_projects_data, 'repositoryID');
14+
if (!$repository_ids) {
15+
return;
16+
}
17+
1418
$repositories = id(new PhabricatorRepositoryQuery())
1519
->setViewer(PhabricatorUser::getOmnipotentUser())
1620
->withIDs($repository_ids)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
2+
ADD isRecurring BOOL NOT NULL;
3+
4+
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
5+
ADD recurrenceFrequency LONGTEXT COLLATE {$COLLATE_TEXT} NOT NULL;
6+
7+
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
8+
ADD recurrenceEndDate INT UNSIGNED;
9+
10+
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
11+
ADD instanceOfEventPHID varbinary(64);
12+
13+
ALTER TABLE {$NAMESPACE}_calendar.calendar_event
14+
ADD sequenceIndex INT UNSIGNED;
15+
16+
UPDATE {$NAMESPACE}_calendar.calendar_event
17+
SET recurrenceFrequency = '[]' WHERE recurrenceFrequency = '';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE {$NAMESPACE}_spaces.spaces_namespace (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
phid VARBINARY(64) NOT NULL,
4+
namespaceName VARCHAR(255) NOT NULL COLLATE {$COLLATE_TEXT},
5+
viewPolicy VARBINARY(64) NOT NULL,
6+
editPolicy VARBINARY(64) NOT NULL,
7+
isDefaultNamespace BOOL,
8+
dateCreated INT UNSIGNED NOT NULL,
9+
dateModified INT UNSIGNED NOT NULL,
10+
UNIQUE KEY `key_phid` (phid),
11+
UNIQUE KEY `key_default` (isDefaultNamespace)
12+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE {$NAMESPACE}_spaces.spaces_namespacetransaction (
2+
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
3+
phid VARBINARY(64) NOT NULL,
4+
authorPHID VARBINARY(64) NOT NULL,
5+
objectPHID VARBINARY(64) NOT NULL,
6+
viewPolicy VARBINARY(64) NOT NULL,
7+
editPolicy VARBINARY(64) NOT NULL,
8+
commentPHID VARBINARY(64),
9+
commentVersion INT UNSIGNED NOT NULL,
10+
transactionType VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT},
11+
oldValue LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
12+
newValue LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
13+
contentSource LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
14+
metadata LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT},
15+
dateCreated INT UNSIGNED NOT NULL,
16+
dateModified INT UNSIGNED NOT NULL,
17+
UNIQUE KEY `key_phid` (phid),
18+
KEY `key_object` (objectPHID)
19+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_user.user
2+
ADD isMailingList BOOL NOT NULL;
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
3+
$conn_w = id(new PhabricatorMetaMTAMail())->establishConnection('w');
4+
$lists = new LiskRawMigrationIterator($conn_w, 'metamta_mailinglist');
5+
6+
echo pht('Migrating mailing lists...')."\n";
7+
8+
foreach ($lists as $list) {
9+
$name = $list['name'];
10+
$email = $list['email'];
11+
$uri = $list['uri'];
12+
$old_phid = $list['phid'];
13+
14+
$username = preg_replace('/[^a-zA-Z0-9_-]+/', '-', $name);
15+
$username = preg_replace('/-{2,}/', '-', $username);
16+
$username = trim($username, '-');
17+
if (!strlen($username)) {
18+
$username = 'mailinglist';
19+
}
20+
$username .= '-list';
21+
22+
$username_okay = false;
23+
for ($suffix = 1; $suffix <= 9; $suffix++) {
24+
if ($suffix == 1) {
25+
$effective_username = $username;
26+
} else {
27+
$effective_username = $username.$suffix;
28+
}
29+
30+
$collision = id(new PhabricatorPeopleQuery())
31+
->setViewer(PhabricatorUser::getOmnipotentUser())
32+
->withUsernames(array($effective_username))
33+
->executeOne();
34+
if (!$collision) {
35+
$username_okay = true;
36+
break;
37+
}
38+
}
39+
40+
if (!$username_okay) {
41+
echo pht(
42+
'Failed to migrate mailing list "%s": unable to generate a unique '.
43+
'username for it.')."\n";
44+
continue;
45+
}
46+
47+
$username = $effective_username;
48+
if (!PhabricatorUser::validateUsername($username)) {
49+
echo pht(
50+
'Failed to migrate mailing list "%s": unable to generate a valid '.
51+
'username for it.',
52+
$name)."\n";
53+
continue;
54+
}
55+
56+
$address = id(new PhabricatorUserEmail())->loadOneWhere(
57+
'address = %s',
58+
$email);
59+
if ($address) {
60+
echo pht(
61+
'Failed to migrate mailing list "%s": an existing user already '.
62+
'has the email address "%s".',
63+
$name,
64+
$email)."\n";
65+
continue;
66+
}
67+
68+
$user = id(new PhabricatorUser())
69+
->setUsername($username)
70+
->setRealName(pht('Mailing List "%s"', $name))
71+
->setIsApproved(1)
72+
->setIsMailingList(1);
73+
74+
$email_object = id(new PhabricatorUserEmail())
75+
->setAddress($email)
76+
->setIsVerified(1);
77+
78+
try {
79+
id(new PhabricatorUserEditor())
80+
->setActor($user)
81+
->createNewUser($user, $email_object);
82+
} catch (Exception $ex) {
83+
echo pht(
84+
'Failed to migrate mailing list "%s": %s.',
85+
$name,
86+
$ex->getMessage())."\n";
87+
continue;
88+
}
89+
90+
$new_phid = $user->getPHID();
91+
92+
// NOTE: After the PHID type is removed we can't use any Edge code to
93+
// modify edges.
94+
95+
$edge_type = PhabricatorSubscribedToObjectEdgeType::EDGECONST;
96+
$edge_inverse = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
97+
98+
$map = PhabricatorPHIDType::getAllTypes();
99+
foreach ($map as $type => $spec) {
100+
try {
101+
$object = $spec->newObject();
102+
if (!$object) {
103+
continue;
104+
}
105+
$object_conn_w = $object->establishConnection('w');
106+
queryfx(
107+
$object_conn_w,
108+
'UPDATE %T SET dst = %s WHERE dst = %s AND type = %s',
109+
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
110+
$new_phid,
111+
$old_phid,
112+
$edge_inverse);
113+
} catch (Exception $ex) {
114+
// Just ignore these; they're mostly tables not existing.
115+
continue;
116+
}
117+
}
118+
119+
try {
120+
$dst_phids = queryfx_all(
121+
$conn_w,
122+
'SELECT dst FROM %T WHERE src = %s AND type = %s',
123+
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
124+
$old_phid,
125+
$edge_type);
126+
if ($dst_phids) {
127+
$editor = new PhabricatorEdgeEditor();
128+
foreach ($dst_phids as $dst_phid) {
129+
$editor->addEdge($new_phid, $edge_type, $dst_phid['dst']);
130+
}
131+
$editor->save();
132+
}
133+
} catch (Exception $ex) {
134+
echo pht(
135+
'Unable to migrate some inverse edges for mailing list "%s": %s.',
136+
$name,
137+
$ex->getMessage())."\n";
138+
continue;
139+
}
140+
141+
echo pht(
142+
'Migrated mailing list "%s" to mailing list user "%s".',
143+
$name,
144+
$user->getUsername())."\n";
145+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_pastebin.pastebin_paste
2+
ADD spacePHID VARBINARY(64);

0 commit comments

Comments
 (0)