-
-
Notifications
You must be signed in to change notification settings - Fork 10
Can't handle non-comments as first post #7
Description
This extension expects $discussion->firstPost to be a CommentPost. The template reads $post->content and expect it to be text.
In the case of my Premium Wordpress extension, the first post may be an EventPost whose content is a JSON object, returned as a PHP array.
The consequence is a PHP notice for Array to string conversion that's rendered in the email if notices are visible, and where the text should be I can read just Array.
I have implemented some workarounds for other extensions. For example the SEO extension calls $post->formatContent(), which I have been able to implement in a way that's compatible with CommentPost.
However I cannot re-implement $post->content, or it would break the functionality of the JSON payload.
In order for the two extensions to work together, Follow Tags should call another method where third-party extensions can provide custom implementations for event posts. Another option would be to ignore non-comment posts, which would remove the enigmatic Array from the email, but would prevent integration with extensions like mine.
My suggestion would be to call formatContent(), and inject the HTML in the email. It would both solve this issue and add formatting. But I'm sure there were some concerns adding the post HTML in the email.
I actually would like to open a proposal in core to add an interface for posts that can be rendered as HTML. That way extensions will be free to register new post types, and other extensions will be able to know whether they can output their content or not.