• Resolved peterhassett

    (@peterhassett)


    Hello, thanks for reading.

    We’re a relatively high-traffic site, and our logs are getting filled up by a PHP warning from Co-Authors Plus that I can’t figure out.

    The error:

    Message
    PHP Warning: Attempt to read property “user_login” on null in /srv/htdocs/wp-content/plugins/co-authors-plus/template-tags.php on line 129
    Timestamp
    2024-10-13T13:07:43.000Z
    Kind
    plugins
    Name
    co-authors-plus
    File
    /srv/htdocs/wp-content/plugins/co-authors-plus/template-tags.php
    Line
    129

    It’s firing multiple times per minute, so I suspect it’s on every load of a page with an entry on it.

    The relevant portion from that plugin file:

    do {
        $author_text = '';
    
        if ( 'tag' === $type ) {
            $author_text = $tag( $tag_args );
        } elseif ( 'field' === $type && isset( $i->current_author->$tag ) ) {
            $author_text = $i->current_author->$tag;
        } elseif ( 'callback' === $type && is_callable( $tag ) ) {
            $author_text = $tag( $i->current_author );
        }
    
        // Fallback to user_login if we get something empty
        if ( empty( $author_text ) ) {
            $author_text = $i->current_author->user_login;
        }

    I can’t figure out what we’re doing wrong here. I’m not clear on what author_text is supposed to do or why it’s null. I figure the error would only fire if the user is logged-out.

    Maybe there’s some workaround if we manually set that value in our loop templates? I’d love any advice; this one has been confounding.

    WordPress 6.6.2 (latest)
    PHP 8.3
    Custom theme based on understrap
    Hosted on WP.com

    • This topic was modified 4 months, 3 weeks ago by peterhassett.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.