Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13968855
D9850.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9850.id.diff
View Options
diff --git a/resources/sql/autopatches/20140706.pedge.1.sql b/resources/sql/autopatches/20140706.pedge.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140706.pedge.1.sql
@@ -0,0 +1,10 @@
+/* PhabricatorProjectObjectHasProjectEdgeType::EDGECONST = 41 */
+/* PhabricatorProjectProjectHasObjectEdgeType::EDGECONST = 42 */
+
+INSERT IGNORE INTO {$NAMESPACE}_maniphest.edge (src, type, dst)
+ SELECT taskPHID, 41, projectPHID
+ FROM {$NAMESPACE}_maniphest.maniphest_taskproject;
+
+INSERT IGNORE INTO {$NAMESPACE}_project.edge (src, type, dst)
+ SELECT projectPHID, 42, taskPHID
+ FROM {$NAMESPACE}_maniphest.maniphest_taskproject;
diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php
--- a/src/applications/maniphest/controller/ManiphestReportController.php
+++ b/src/applications/maniphest/controller/ManiphestReportController.php
@@ -83,9 +83,10 @@
$joins = qsprintf(
$conn,
'JOIN %T t ON x.objectPHID = t.phid
- JOIN %T p ON p.taskPHID = t.phid AND p.projectPHID = %s',
+ JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s',
id(new ManiphestTask())->getTableName(),
- id(new ManiphestTaskProject())->getTableName(),
+ PhabricatorEdgeConfig::TABLE_NAME_EDGE,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
$project_phid);
}
diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php
--- a/src/applications/maniphest/query/ManiphestTaskQuery.php
+++ b/src/applications/maniphest/query/ManiphestTaskQuery.php
@@ -243,7 +243,7 @@
// query. We sum the project count and require it be the same as the
// number of projects we're searching for.
- $count = ', COUNT(project.projectPHID) projectCount';
+ $count = ', COUNT(project.dst) projectCount';
$having = qsprintf(
$conn,
'HAVING projectCount = %d',
@@ -496,13 +496,13 @@
if ($this->projectPHIDs) {
$parts[] = qsprintf(
$conn,
- 'project.projectPHID in (%Ls)',
+ 'project.dst in (%Ls)',
$this->projectPHIDs);
}
if ($this->includeNoProject) {
$parts[] = qsprintf(
$conn,
- 'project.projectPHID IS NULL');
+ 'project.dst IS NULL');
}
return '('.implode(') OR (', $parts).')';
@@ -515,7 +515,7 @@
return qsprintf(
$conn,
- 'anyproject.projectPHID IN (%Ls)',
+ 'anyproject.dst IN (%Ls)',
$this->anyProjectPHIDs);
}
@@ -536,7 +536,7 @@
return qsprintf(
$conn,
- 'anyproject.projectPHID IN (%Ls)',
+ 'anyproject.dst IN (%Ls)',
$any_user_project_phids);
}
@@ -547,7 +547,7 @@
return qsprintf(
$conn,
- 'xproject.projectPHID IS NULL');
+ 'xproject.dst IS NULL');
}
private function buildCustomOrderClause(AphrontDatabaseConnection $conn) {
@@ -636,31 +636,37 @@
}
private function buildJoinsClause(AphrontDatabaseConnection $conn_r) {
- $project_dao = new ManiphestTaskProject();
+ $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE;
$joins = array();
if ($this->projectPHIDs || $this->includeNoProject) {
$joins[] = qsprintf(
$conn_r,
- '%Q JOIN %T project ON project.taskPHID = task.phid',
+ '%Q JOIN %T project ON project.src = task.phid
+ AND project.type = %d',
($this->includeNoProject ? 'LEFT' : ''),
- $project_dao->getTableName());
+ $edge_table,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
if ($this->anyProjectPHIDs || $this->anyUserProjectPHIDs) {
$joins[] = qsprintf(
$conn_r,
- 'JOIN %T anyproject ON anyproject.taskPHID = task.phid',
- $project_dao->getTableName());
+ 'JOIN %T anyproject ON anyproject.src = task.phid
+ AND anyproject.type = %d',
+ $edge_table,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
if ($this->xprojectPHIDs) {
$joins[] = qsprintf(
$conn_r,
- 'LEFT JOIN %T xproject ON xproject.taskPHID = task.phid
- AND xproject.projectPHID IN (%Ls)',
- $project_dao->getTableName(),
+ 'LEFT JOIN %T xproject ON xproject.src = task.phid
+ AND xproject.type = %d
+ AND xproject.dst IN (%Ls)',
+ $edge_table,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
$this->xprojectPHIDs);
}
@@ -678,20 +684,24 @@
if ($ignore_group_phids) {
$joins[] = qsprintf(
$conn_r,
- 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.taskPHID
- AND projectGroup.projectPHID NOT IN (%Ls)',
- $project_dao->getTableName(),
+ 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src
+ AND projectGroup.type = %d
+ AND projectGroup.dst NOT IN (%Ls)',
+ $edge_table,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
$ignore_group_phids);
} else {
$joins[] = qsprintf(
$conn_r,
- 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.taskPHID',
- $project_dao->getTableName());
+ 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src
+ AND projectGroup.type = %d',
+ $edge_table,
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
}
$joins[] = qsprintf(
$conn_r,
'LEFT JOIN %T projectGroupName
- ON projectGroup.projectPHID = projectGroupName.indexedObjectPHID',
+ ON projectGroup.dst = projectGroupName.indexedObjectPHID',
id(new ManiphestNameIndex())->getTableName());
break;
}
@@ -712,7 +722,7 @@
// task IDs.
if ($joined_multiple_rows) {
if ($joined_project_name) {
- return 'GROUP BY task.phid, projectGroup.projectPHID';
+ return 'GROUP BY task.phid, projectGroup.dst';
} else {
return 'GROUP BY task.phid';
}
diff --git a/src/applications/maniphest/storage/ManiphestTaskProject.php b/src/applications/maniphest/storage/ManiphestTaskProject.php
--- a/src/applications/maniphest/storage/ManiphestTaskProject.php
+++ b/src/applications/maniphest/storage/ManiphestTaskProject.php
@@ -20,30 +20,29 @@
}
public static function updateTaskProjects(ManiphestTask $task) {
- $dao = new ManiphestTaskProject();
- $conn = $dao->establishConnection('w');
-
- $sql = array();
- foreach ($task->getProjectPHIDs() as $project_phid) {
- $sql[] = qsprintf(
- $conn,
- '(%s, %s)',
- $task->getPHID(),
- $project_phid);
+ $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
+
+ $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $task->getPHID(),
+ $edge_type);
+ $new_phids = $task->getProjectPHIDs();
+
+ $add_phids = array_diff($new_phids, $old_phids);
+ $rem_phids = array_diff($old_phids, $new_phids);
+
+ if (!$add_phids && !$rem_phids) {
+ return;
}
- queryfx(
- $conn,
- 'DELETE FROM %T WHERE taskPHID = %s',
- $dao->getTableName(),
- $task->getPHID());
- if ($sql) {
- queryfx(
- $conn,
- 'INSERT INTO %T (taskPHID, projectPHID) VALUES %Q',
- $dao->getTableName(),
- implode(', ', $sql));
+
+ $editor = new PhabricatorEdgeEditor();
+ foreach ($add_phids as $phid) {
+ $editor->addEdge($task->getPHID(), $edge_type, $phid);
+ }
+ foreach ($rem_phids as $phid) {
+ $editor->remEdge($task->getPHID(), $edge_type, $phid);
}
+ $editor->save();
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 17, 11:05 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716824
Default Alt Text
D9850.id.diff (7 KB)
Attached To
Mode
D9850: Move task/project storage to edges
Attached
Detach File
Event Timeline
Log In to Comment