1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 17:22:42 +01:00
phorge-phorge/resources/sql/autopatches/20151223.proj.05.updatekeys.php
epriestley 70f6bf306f Implement child/descendant query rules in Projects
Summary:
Ref T10010. This adds infrastructure for querying projects by type, depth, parent and ancestor.

I needed to revise the "extended policy check" cycle detection rules. When, e.g., querying a grandchild, they incorrectly detected a cycle because both the child and grandchild needed to check the policy of the grandparent.

Instead, simplify it to just do a basic runaway calldepth check. There are many other safety mechanisms to make it so this can't ever occur.

(Cycle detection does have existing test coverage, and those tests still pass, it just takes a little longer to detect the cycle internally.)

There is still no way to create subprojects in the UI.

Test Plan: Added and executed unit tests.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10010

Differential Revision: https://secure.phabricator.com/D14862
2015-12-23 14:38:51 -08:00

24 lines
582 B
PHP

<?php
$table = new PhabricatorProject();
$conn_w = $table->establishConnection('w');
foreach (new LiskMigrationIterator($table) as $project) {
$path = $project->getProjectPath();
$key = $project->getProjectPathKey();
if (strlen($path) && ($key !== "\0\0\0\0")) {
continue;
}
$path_key = PhabricatorHash::digestForIndex($project->getPHID());
$path_key = substr($path_key, 0, 4);
queryfx(
$conn_w,
'UPDATE %T SET projectPath = %s, projectPathKey = %s WHERE id = %d',
$project->getTableName(),
$path_key,
$path_key,
$project->getID());
}