Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
Show First 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | |||||||||
$maniphest = 'PhabricatorManiphestApplication'; | $maniphest = 'PhabricatorManiphestApplication'; | |||||||||
if (PhabricatorApplication::isClassInstalled($maniphest)) { | if (PhabricatorApplication::isClassInstalled($maniphest)) { | |||||||||
$diff = $this->requireDiff($xaction->getNewValue()); | $diff = $this->requireDiff($xaction->getNewValue()); | |||||||||
$branch = $diff->getBranch(); | $branch = $diff->getBranch(); | |||||||||
// No "$", to allow for branches like T123_demo. | // No "$", to allow for branches like T123_demo. | |||||||||
$match = null; | $match = null; | |||||||||
if (preg_match('/^T(\d+)/i', $branch, $match)) { | if ($branch !== null && preg_match('/^T(\d+)/i', $branch, $match)) { | |||||||||
$task_id = $match[1]; | $task_id = $match[1]; | |||||||||
$tasks = id(new ManiphestTaskQuery()) | $tasks = id(new ManiphestTaskQuery()) | |||||||||
->setViewer($this->getActor()) | ->setViewer($this->getActor()) | |||||||||
->withIDs(array($task_id)) | ->withIDs(array($task_id)) | |||||||||
->execute(); | ->execute(); | |||||||||
if ($tasks) { | if ($tasks) { | |||||||||
$task = head($tasks); | $task = head($tasks); | |||||||||
$task_phid = $task->getPHID(); | $task_phid = $task->getPHID(); | |||||||||
$results[] = id(new DifferentialTransaction()) | $results[] = id(new DifferentialTransaction()) | |||||||||
->setTransactionType($type_edge) | ->setTransactionType($type_edge) | |||||||||
->setMetadataValue('edge:type', $edge_ref_task) | ->setMetadataValue('edge:type', $edge_ref_task) | |||||||||
->setIgnoreOnNoEffect(true) | ->setIgnoreOnNoEffect(true) | |||||||||
->setNewValue(array('+' => array($task_phid => $task_phid))); | ->setNewValue(array('+' => array($task_phid => $task_phid))); | |||||||||
speck: `$match` is always null here, see the immediate line above. It's probably a bit weird but… | ||||||||||
} | } | |||||||||
Not Done Inline ActionsI think it might be clearer as if ($branch != null && preg_match(....)) { Also, I think this feature (attaching revision to task based on user's branch) is not documented? avivey: I think it might be clearer as
```
if ($branch != null && preg_match(....)) {
```
Also, I… | ||||||||||
Not Done Inline Actions
Please make this edit speck: Please make this edit | ||||||||||
} | } | |||||||||
} | } | |||||||||
break; | break; | |||||||||
case DifferentialRevisionCommandeerTransaction::TRANSACTIONTYPE: | case DifferentialRevisionCommandeerTransaction::TRANSACTIONTYPE: | |||||||||
$new_author_phid = $actor_phid; | $new_author_phid = $actor_phid; | |||||||||
break; | break; | |||||||||
▲ Show 20 Lines • Show All 1,446 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
$match is always null here, see the immediate line above. It's probably a bit weird but preg_match uses it as an "out" parameter, so after calling that it will be populated with a value.