diff --git a/src/applications/feed/PhabricatorFeedStoryPublisher.php b/src/applications/feed/PhabricatorFeedStoryPublisher.php index 6d968042aa..0262f86af9 100644 --- a/src/applications/feed/PhabricatorFeedStoryPublisher.php +++ b/src/applications/feed/PhabricatorFeedStoryPublisher.php @@ -61,10 +61,25 @@ final class PhabricatorFeedStoryPublisher { } public function publish() { - if (!$this->storyType) { + $class = $this->storyType; + if (!$class) { throw new Exception("Call setStoryType() before publishing!"); } + if (!class_exists($class)) { + throw new Exception( + "Story type must be a valid class name and must subclass ". + "PhabricatorFeedStory. ". + "'{$class}' is not a loadable class."); + } + + if (!is_subclass_of($class, 'PhabricatorFeedStory')) { + throw new Exception( + "Story type must be a valid class name and must subclass ". + "PhabricatorFeedStory. ". + "'{$class}' is not a subclass of PhabricatorFeedStory."); + } + $chrono_key = $this->generateChronologicalKey(); $story = new PhabricatorFeedStoryData();