Don't require a previous Post when saving event posts

A bit of an edge-case since it shouldn't really be possible to have a discussion with zero posts anymore, but when renaming an empty discussion (or taking any action that will create an "event post"), Flarum would crash. This is due to the MergeableInterface requiring these posts to be saved after a previous post.
This commit is contained in:
Toby Zerner 2016-02-29 18:50:27 +10:30
parent 56b39f9fba
commit 24713733fc
2 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterf
/**
* {@inheritdoc}
*/
public function saveAfter(Post $previous)
public function saveAfter(Post $previous = null)
{
// If the previous post is another 'discussion renamed' post, and it's
// by the same user, then we can merge this post into it. If we find

View File

@ -25,10 +25,10 @@ interface MergeableInterface
* Save the model, given that it is going to appear immediately after the
* passed model.
*
* @param Post $previous
* @param Post|null $previous
* @return Post The model resulting after the merge. If the merge is
* unsuccessful, this should be the current model instance. Otherwise,
* it should be the model that was merged into.
*/
public function saveAfter(Post $previous);
public function saveAfter(Post $previous = null);
}