Co-Authors-Plus icon indicating copy to clipboard operation
Co-Authors-Plus copied to clipboard

PHP warning when post has no author

Open peterhassett opened this issue 1 year ago • 0 comments

This is an edge case.

If a post (or attachment) has no post_author value, when an end-user loads its front-end page, a PHP warning is fired:

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-19T18:44:40.000Z Kind plugins Name co-authors-plus File /srv/htdocs/wp-content/plugins/co-authors-plus/template-tags.php Line 129

Specifically, I think it's this bit: $author_text = $i->current_author->user_login;, wherein the current_author is null.

I suppose posts without authors is technically invalid, but I figured I'd at least raise the issue here, just in case. This cause/d our site to fire a ton of errors -- many a minute -- filling up our logs.

Thank you!

peterhassett avatar Oct 19 '24 18:10 peterhassett