Closed biophonc closed 2 years ago
Hi @biophonc,
If this is still happening on your site, could you try outputting the global post object before the get_coauthors
function is called to check its value?
It sounds like the post object has been inadvertently set to an integer, maybe in your theme or by another plugin or with something you're testing? Or possibly, could be calling get_coauthors
from outside the loop where the post object doesn't exist?
Hi @lschuyler,
Unfortunately I'm currently using a patched version of co authors (using this repo as upstream) but I'll prepare a test to see whether it's most likely caused by a 3rd party plugin, my theme or the co authors plugin.
Hi @lschuyler,
I finally have found the time to investigate the issue further, and you were right, it was caused by my theme that:
global $post
in one template, without being encapsulated (haven't noticed it earlier)foreach
loop for a SearchWP result set, that simplified did this:
foreach ($related_content as $post) { // note: $post is still global here and thus gets overwritten
setup_postdata($post);
}
wp_reset_postdata();
I've also tested it with a fresh installation of WP 6.0 on PHP 8, with the twentyone theme and everything works fine as expected :-) This means it's not a Co-Authors-Plus bug.
I feel so stupid right now, because the cause was so obvious :facepalm:. This probably happens only, when you work on a codebase for 5 years+ and it's your own ^^
Thanks!
Environment: PHP 8.0, WP 5.9+
Hi, my PHP log is flooded with these entries for a while:
[08-Jun-2022 10:10:10] WARNING: [pool foo] child 32581 said into stderr: "NOTICE: PHP message: PHP Warning: Attempt to read property "ID" on int in /var/www/foo/wp-content/plugins/co-authors-plus/template-tags.php on line 13"
Basically, it's this condition:
Both
$post_id
and$post
are integers. This means, that inget_coauthors()
the$post_id
will always be0
, resulting in, that the final filter will always be called with these values:The function
is_coauthor_for_post()
will permanently return early, with the valuefalse
because of this.