No PHP notices to appear in debug.log.
debug.log is filled with PHP notices similar to the following:
PHP Notice: Undefined property: WP_Post_Type::$post_name in /app/public/wp-includes/class-wp-query.php on line 3960
PHP Notice: Undefined property: WP_Post_Type::$ID in /app/public/wp-includes/class-wp-query.php on line 3956
PHP Notice: Undefined property: WP_Post_Type::$post_title in /app/public/wp-includes/class-wp-query.php on line 3958
PHP Notice: Undefined property: WP_Post_Type::$post_name in /app/public/wp-includes/class-wp-query.php on line 3960
PHP Notice: Undefined property: WP_Post_Type::$post_type in /app/public/wp-content/plugins/sensei-lms/includes/class-sensei-posttypes.php on line 906
The last notice is of particular importance as it's coming directly from Sensei LMS.
This was found while testing https://github.com/Automattic/sensei-wc-paid-courses/pull/146, which doesn't load the CSS file on Divi or GeneratePress because the following check fails. There may be other side effects that we're not aware of:
https://github.com/Automattic/sensei-wc-paid-courses/pull/146/files#diff-37b96f48999247da387df43ba2a8604cR65
I suspect that this may be related to theme compatibility, which alters queried_object.
I took a quick look at this. It appears that this may be the result of not messing with queried_object quite enough 馃槄
In this code we create a dummy post object for rendering archive page content. Then we override the global $wp_query to seem like it has loaded that dummy post from the database, and then trick the theme into thinking that it should be rendering the "single post" template.
Although we do set several attributes of the new $wp_query in that code (including post), we do not actually set queried_object. So on the course archive page, get_queried_object() still returns the post type, even though the theme (i.e. Divi) is rendering the "single post" template. I believe this is why it looks like we are trying to access several WP_Post attributes on a WP_Post_Type object (e.g. post_name, ID, post_type).
Adding these two lines to the code linked above seemed to fix the problem for me:
$wp_query->queried_object = $post;
$wp_query->queried_object_id = $post->ID;
So that will be a good starting point for this one, but we'll want to test thoroughly to make sure that it doesn't have other implications.
Same thing happens with Hello Elementor theme, reported here: https://wordpress.org/support/topic/undefined-property-wp_post_typeid/
Most helpful comment
I took a quick look at this. It appears that this may be the result of not messing with
queried_objectquite enough 馃槄In this code we create a dummy post object for rendering archive page content. Then we override the global
$wp_queryto seem like it has loaded that dummy post from the database, and then trick the theme into thinking that it should be rendering the "single post" template.Although we do set several attributes of the new
$wp_queryin that code (includingpost), we do not actually setqueried_object. So on the course archive page,get_queried_object()still returns the post type, even though the theme (i.e. Divi) is rendering the "single post" template. I believe this is why it looks like we are trying to access severalWP_Postattributes on aWP_Post_Typeobject (e.g.post_name,ID,post_type).Adding these two lines to the code linked above seemed to fix the problem for me:
So that will be a good starting point for this one, but we'll want to test thoroughly to make sure that it doesn't have other implications.