From b3900a399cfd410fad40b6003f835cf614673b8d Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 26 Jun 2012 05:48:14 -0700 Subject: [PATCH] Minor, allow feed stories to publish with no related PHIDs (commits, future notifications). --- .../feed/PhabricatorFeedStoryPublisher.php | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/applications/feed/PhabricatorFeedStoryPublisher.php b/src/applications/feed/PhabricatorFeedStoryPublisher.php index 811160e151..20e8f1d817 100644 --- a/src/applications/feed/PhabricatorFeedStoryPublisher.php +++ b/src/applications/feed/PhabricatorFeedStoryPublisher.php @@ -61,10 +61,6 @@ final class PhabricatorFeedStoryPublisher { } public function publish() { - if (!$this->relatedPHIDs) { - throw new Exception("There are no PHIDs related to this story!"); - } - if (!$this->storyType) { throw new Exception("Call setStoryType() before publishing!"); } @@ -78,24 +74,26 @@ final class PhabricatorFeedStoryPublisher { $story->setChronologicalKey($chrono_key); $story->save(); - $ref = new PhabricatorFeedStoryReference(); + if ($this->relatedPHIDs) { + $ref = new PhabricatorFeedStoryReference(); - $sql = array(); - $conn = $ref->establishConnection('w'); - foreach (array_unique($this->relatedPHIDs) as $phid) { - $sql[] = qsprintf( + $sql = array(); + $conn = $ref->establishConnection('w'); + foreach (array_unique($this->relatedPHIDs) as $phid) { + $sql[] = qsprintf( + $conn, + '(%s, %s)', + $phid, + $chrono_key); + } + + queryfx( $conn, - '(%s, %s)', - $phid, - $chrono_key); + 'INSERT INTO %T (objectPHID, chronologicalKey) VALUES %Q', + $ref->getTableName(), + implode(', ', $sql)); } - queryfx( - $conn, - 'INSERT INTO %T (objectPHID, chronologicalKey) VALUES %Q', - $ref->getTableName(), - implode(', ', $sql)); - if (PhabricatorEnv::getEnvConfig('notification.enabled')) { $this->insertNotifications($chrono_key); $this->sendNotification($chrono_key);