Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

Error when trying to render latest message in LatestPosts widget from unknown author #129

Open
eLFuvo opened this issue Nov 18, 2017 · 0 comments
Assignees
Labels

Comments

@eLFuvo
Copy link

eLFuvo commented Nov 18, 2017

When author of latest post is removed I have this error:

Trying to get property of non-object
 in @vendor/bizley/podium/src/views/elements/forum/_forum.php

patch this please in src/views/elements/forum/_forum.php:24 as follow

if (!empty($model->latest) && !empty($model->latest->author) && !empty($model->latest->thread)):

and src/models/Post.php:338

$latest[] = [
                    'id' => $post->id,
                    'title' => $post->thread->name,
                    'created' => $post->created_at,
                    'author' => $post->author ? $post->author->podiumTag : null,
                ];

or fix those methods by adding relation check

public static function getLatestPostsForMembers($limit = 5)
    {
        return static::find()
            ->joinWith('author', false, 'INNER JOIN')
            ->orderBy(['created_at' => SORT_DESC])->limit($limit)->all();
    }

...

public static function getLatestPostsForGuests($limit = 5)
    {
        return static::find()
            ->joinWith('author', false, 'INNER JOIN')
            ->joinWith(['forum' => function ($query) {
            $query->andWhere([Forum::tableName() . '.visible' => 1])->joinWith(['category' => function ($query) {
                $query->andWhere([Category::tableName() . '.visible' => 1]);
            }]);
        }])->orderBy(['created_at' => SORT_DESC])->limit($limit)->all();
    }
@eLFuvo eLFuvo changed the title Error when trying to render latest message in thread list from unknown author Error when trying to render latest message inLatestPosts widget from unknown author Nov 18, 2017
@eLFuvo eLFuvo changed the title Error when trying to render latest message inLatestPosts widget from unknown author Error when trying to render latest message in LatestPosts widget from unknown author Nov 18, 2017
@bizley bizley self-assigned this Nov 20, 2017
@bizley bizley added the bug label Nov 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants