Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forum topic cover handling #11227

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Http/Controllers/Forum/TopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ public function show($id)
$topic->incrementViewCount($currentUser, \Request::ip());
$posts->last()->markRead($currentUser);

$coverModel = $topic->cover ?? new TopicCover();
// Instantiate new cover model separately to prevent it from getting used by opengraph
$coverModel = $topic->cover ?? new TopicCover(['topic_id' => $topic->getKey()]);
$coverModel->setRelation('topic', $topic);
$cover = json_item($coverModel, new TopicCoverTransformer());

Expand Down
2 changes: 1 addition & 1 deletion app/Transformers/Forum/TopicCoverTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TopicCoverTransformer extends TransformerAbstract
{
public function transform(TopicCover $cover)
{
if ($cover->file_json === null) {
if ($cover->filename === null) {
$data = [
'method' => 'post',
'url' => route('forum.topic-covers.store', [
Expand Down