From 279790377654aebbe35d190db051b81233b64a2e Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 4 Dec 2011 13:03:12 -0800 Subject: [PATCH] Fix bad query edge condition when updating a revision with no attached tasks. --- ...ifferentialManiphestTasksFieldSpecification.php | 14 ++++++++++---- src/storage/qsprintf/qsprintf.php | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php b/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php index bd1f9c298d..345520e4ca 100644 --- a/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php +++ b/src/applications/differential/field/specification/maniphesttasks/DifferentialManiphestTasksFieldSpecification.php @@ -69,10 +69,13 @@ final class DifferentialManiphestTasksFieldSpecification $user = $this->getUser(); $type = ManiphestTransactionType::TYPE_ATTACH; $attach_type = PhabricatorPHIDConstants::PHID_TYPE_DREV; - $attach_data = array($revision->getPHID() => array()); - $tasks = id(new ManiphestTask()) - ->loadAllWhere('phid IN (%Ld)', $this->maniphestTasks); + $tasks = array(); + if ($this->maniphestTasks) { + $tasks = id(new ManiphestTask())->loadAllWhere( + 'phid IN (%Ls)', + $this->maniphestTasks); + } foreach ($tasks as $task) { $transaction = new ManiphestTransaction(); @@ -80,7 +83,10 @@ final class DifferentialManiphestTasksFieldSpecification $transaction->setTransactionType($type); $new = $task->getAttached(); - $new[$attach_type] = $attach_data; + if (empty($new[$attach_type])) { + $new[$attach_type] = array(); + } + $new[$attach_type][$revision->getPHID] = array(); $transaction->setNewValue($new); $maniphest_editor->applyTransactions($task, array($transaction)); diff --git a/src/storage/qsprintf/qsprintf.php b/src/storage/qsprintf/qsprintf.php index befb0f4c73..d955417cef 100644 --- a/src/storage/qsprintf/qsprintf.php +++ b/src/storage/qsprintf/qsprintf.php @@ -283,6 +283,11 @@ function _qsprintf_check_scalar_type($value, $type, $query) { $query, "Expected a scalar or null for %{$type} conversion."); } + if (!is_numeric($value)) { + throw new AphrontQueryParameterException( + $query, + "Expected numeric value for %{$type} conversion."); + } break; case 'Ls': case 's':