From 3d8d98bd8deb86e1cd6d988415878d365d9e47d4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 14 Dec 2016 14:05:37 -0800 Subject: [PATCH] Probably (?) fix two very old project slug migrations Summary: Fixes T12020. These callsites to `getPhrictionSlug()` were missed when that method was removed. They're very old (early 2014, late 2011). Test Plan: These are tricky to test because the migrations are so ancient, but `bin/storage upgrade --force --apply phabricator:20140521.projectslug.2.mig.php` gave me //plausible// results. The other migration is so ancient that it can't apply to a modern database so I'm just kind of winging that one. We probably have essentially no installs which will ever apply it again, though. Reviewers: chad, avivey Reviewed By: avivey Maniphest Tasks: T12020 Differential Revision: https://secure.phabricator.com/D17060 --- .../sql/autopatches/20140521.projectslug.2.mig.php | 13 ++++++++----- .../sql/patches/090.forceuniqueprojectnames.php | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/resources/sql/autopatches/20140521.projectslug.2.mig.php b/resources/sql/autopatches/20140521.projectslug.2.mig.php index ca6ccf886a..e0ad4b5070 100644 --- a/resources/sql/autopatches/20140521.projectslug.2.mig.php +++ b/resources/sql/autopatches/20140521.projectslug.2.mig.php @@ -4,27 +4,30 @@ $project_table = new PhabricatorProject(); $table_name = $project_table->getTableName(); $conn_w = $project_table->establishConnection('w'); $slug_table_name = id(new PhabricatorProjectSlug())->getTableName(); -$time = time(); +$time = PhabricatorTime::getNow(); -echo pht('Migrating project phriction slugs...')."\n"; +echo pht('Migrating projects to slugs...')."\n"; foreach (new LiskMigrationIterator($project_table) as $project) { $id = $project->getID(); echo pht('Migrating project %d...', $id)."\n"; - $phriction_slug = rtrim($project->getPhrictionSlug(), '/'); + + $slug_text = PhabricatorSlug::normalizeProjectSlug($project->getName()); $slug = id(new PhabricatorProjectSlug()) - ->loadOneWhere('slug = %s', $phriction_slug); + ->loadOneWhere('slug = %s', $slug_text); + if ($slug) { echo pht('Already migrated %d... Continuing.', $id)."\n"; continue; } + queryfx( $conn_w, 'INSERT INTO %T (projectPHID, slug, dateCreated, dateModified) '. 'VALUES (%s, %s, %d, %d)', $slug_table_name, $project->getPHID(), - $phriction_slug, + $slug_text, $time, $time); echo pht('Migrated %d.', $id)."\n"; diff --git a/resources/sql/patches/090.forceuniqueprojectnames.php b/resources/sql/patches/090.forceuniqueprojectnames.php index a3e029d50a..486856c1c3 100644 --- a/resources/sql/patches/090.forceuniqueprojectnames.php +++ b/resources/sql/patches/090.forceuniqueprojectnames.php @@ -96,7 +96,9 @@ function rename_project($project, $projects) { if ($other->getID() == $project->getID()) { continue; } - if ($other->getPhrictionSlug() == $new_slug) { + + $other_slug = PhabricatorSlug::normalizeProjectSlug($other->getName()); + if ($other_slug == $new_slug) { $okay = false; break; }