Page MenuHomePhabricator

D20107.id48015.diff
No OneTemporary

D20107.id48015.diff

diff --git a/resources/sql/patches/20130611.migrateoauth.php b/resources/sql/patches/20130611.migrateoauth.php
--- a/resources/sql/patches/20130611.migrateoauth.php
+++ b/resources/sql/patches/20130611.migrateoauth.php
@@ -1,66 +1,14 @@
<?php
-// NOTE: We aren't using PhabricatorUserOAuthInfo anywhere here because it is
-// getting nuked in a future diff.
-
$table = new PhabricatorUser();
+$conn = $table->establishConnection('w');
$table_name = 'user_oauthinfo';
-$conn_w = $table->establishConnection('w');
-
-$xaccount = new PhabricatorExternalAccount();
-
-echo pht('Migrating OAuth to %s...', 'ExternalAccount')."\n";
-$domain_map = array(
- 'disqus' => 'disqus.com',
- 'facebook' => 'facebook.com',
- 'github' => 'github.com',
- 'google' => 'google.com',
-);
-
-try {
- $phabricator_oauth_uri = new PhutilURI(
- PhabricatorEnv::getEnvConfig('phabricator.oauth-uri'));
- $domain_map['phabricator'] = $phabricator_oauth_uri->getDomain();
-} catch (Exception $ex) {
- // Ignore; this likely indicates that we have removed `phabricator.oauth-uri`
- // in some future diff.
+foreach (new LiskMigrationIterator($conn, $table_name) as $row) {
+ throw new Exception(
+ pht(
+ 'Your Phabricator install has ancient OAuth account data and is '.
+ 'too old to upgrade directly to a modern version of Phabricator. '.
+ 'Upgrade to a version released between June 2013 and February 2019 '.
+ 'first, then upgrade to a modern version.'));
}
-
-$rows = queryfx_all(
- $conn_w,
- 'SELECT * FROM user_oauthinfo');
-foreach ($rows as $row) {
- echo pht('Migrating row ID #%d.', $row['id'])."\n";
- $user = id(new PhabricatorUser())->loadOneWhere(
- 'id = %d',
- $row['userID']);
- if (!$user) {
- echo pht('Bad user ID!')."\n";
- continue;
- }
-
- $domain = idx($domain_map, $row['oauthProvider']);
- if (empty($domain)) {
- echo pht('Unknown OAuth provider!')."\n";
- continue;
- }
-
-
- $xaccount = id(new PhabricatorExternalAccount())
- ->setUserPHID($user->getPHID())
- ->setAccountType($row['oauthProvider'])
- ->setAccountDomain($domain)
- ->setAccountID($row['oauthUID'])
- ->setAccountURI($row['accountURI'])
- ->setUsername($row['accountName'])
- ->setDateCreated($row['dateCreated']);
-
- try {
- $xaccount->save();
- } catch (Exception $ex) {
- phlog($ex);
- }
-}
-
-echo pht('Done.')."\n";
diff --git a/resources/sql/patches/20130611.nukeldap.php b/resources/sql/patches/20130611.nukeldap.php
--- a/resources/sql/patches/20130611.nukeldap.php
+++ b/resources/sql/patches/20130611.nukeldap.php
@@ -1,41 +1,14 @@
<?php
-// NOTE: We aren't using PhabricatorUserLDAPInfo anywhere here because it is
-// being nuked by this change
-
$table = new PhabricatorUser();
+$conn = $table->establishConnection('w');
$table_name = 'user_ldapinfo';
-$conn_w = $table->establishConnection('w');
-
-$xaccount = new PhabricatorExternalAccount();
-
-echo pht('Migrating LDAP to %s...', 'ExternalAccount')."\n";
-
-$rows = queryfx_all($conn_w, 'SELECT * FROM %T', $table_name);
-foreach ($rows as $row) {
- echo pht('Migrating row ID #%d.', $row['id'])."\n";
- $user = id(new PhabricatorUser())->loadOneWhere(
- 'id = %d',
- $row['userID']);
- if (!$user) {
- echo pht('Bad user ID!')."\n";
- continue;
- }
-
- $xaccount = id(new PhabricatorExternalAccount())
- ->setUserPHID($user->getPHID())
- ->setAccountType('ldap')
- ->setAccountDomain('self')
- ->setAccountID($row['ldapUsername'])
- ->setUsername($row['ldapUsername'])
- ->setDateCreated($row['dateCreated']);
-
- try {
- $xaccount->save();
- } catch (Exception $ex) {
- phlog($ex);
- }
+foreach (new LiskMigrationIterator($conn, $table_name) as $row) {
+ throw new Exception(
+ pht(
+ 'Your Phabricator install has ancient LDAP account data and is '.
+ 'too old to upgrade directly to a modern version of Phabricator. '.
+ 'Upgrade to a version released between June 2013 and February 2019 '.
+ 'first, then upgrade to a modern version.'));
}
-
-echo pht('Done.')."\n";

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 7, 9:37 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7351225
Default Alt Text
D20107.id48015.diff (4 KB)

Event Timeline