Skip to content

Commit 48a3760

Browse files
author
epriestley
committedJan 31, 2019
Correct a bug where milestone "spacePHID" columns could become desynchronized
Summary: Depends on D20041. See PHI1046. If you do this: - Create a parent project called "Crab" in Space 1. - Create a milestone called "Left Claw". - Shift "Crab" to Space 2. - Create a milestone called "Right Claw". ...you currently end up with "Left Claw" in the wrong `spacePHID` in the database. At the application level it's in the correct space, but when we `WHERE ... AND spacePHID IN (...)` we can incorrectly filter it out. Test Plan: - Did the above setup. - Saved "Crab", saw the space fix itself. - Put things back in the broken state. - Ran the migration script, saw things fix themselves again. Reviewers: amckinley Reviewed By: amckinley Subscribers: aeiser, PHID-OPKG-gm6ozazyms6q6i22gyam Differential Revision: https://secure.phabricator.com/D20063
1 parent e9b2d66 commit 48a3760

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
// See PHI1046. The "spacePHID" column for milestones may have fallen out of
4+
// sync; correct all existing values.
5+
6+
$table = new PhabricatorProject();
7+
$conn = $table->establishConnection('w');
8+
$table_name = $table->getTableName();
9+
10+
foreach (new LiskRawMigrationIterator($conn, $table_name) as $project_row) {
11+
queryfx(
12+
$conn,
13+
'UPDATE %R SET spacePHID = %ns
14+
WHERE parentProjectPHID = %s AND milestoneNumber IS NOT NULL',
15+
$table,
16+
$project_row['spacePHID'],
17+
$project_row['phid']);
18+
}

‎src/applications/project/editor/PhabricatorProjectTransactionEditor.php

+11
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ protected function applyFinalEffects(
249249
->rematerialize($new_parent);
250250
}
251251

252+
// See PHI1046. Milestones are always in the Space of their parent project.
253+
// Synchronize the database values to match the application values.
254+
$conn = $object->establishConnection('w');
255+
queryfx(
256+
$conn,
257+
'UPDATE %R SET spacePHID = %ns
258+
WHERE parentProjectPHID = %s AND milestoneNumber IS NOT NULL',
259+
$object,
260+
$object->getSpacePHID(),
261+
$object->getPHID());
262+
252263
return parent::applyFinalEffects($object, $xactions);
253264
}
254265

0 commit comments

Comments
 (0)
Failed to load comments.