mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 18:41:10 +08:00
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:
parent
56b39f9fba
commit
24713733fc
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user