Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
540 stars 198 forks source link

fatal error: Argument 2 passed to Sensei_PostTypes::lesson_is_protected() must be an instance of WP_Post #4034

Closed axyz closed 3 years ago

axyz commented 3 years ago

Sorry as I'm not sure how to reproduce it, but I feel it may be something that may ring a bell from the error logs.

I have an extremely simple sample page to try out sensei with a single course and a single lesson, while it seem to work well, the plugin seem to create problems with some wordpress endpoints.

In this specific case I was not able to sync woocommerce articles via pintful integration (printful complained about a 500 error)

I digged into wp logs and noticed that this error was logged every time the sync was requested:

[04-Mar-2021 09:31:29 UTC] PHP Fatal error:  Uncaught TypeError: Argument 2 passed to Sensei_PostTypes::lesson_is_protected() must be an instance of WP_Post, null given, called in /home/eikonaph/public_html/wp-includes/class-wp-hook.php on line 287 and defined in /home/eikonaph/public_html/wp-content/plugins/sensei-lms/includes/class-sensei-posttypes.php:174
Stack trace:
#0 /home/eikonaph/public_html/wp-includes/class-wp-hook.php(287): Sensei_PostTypes->lesson_is_protected(false, NULL)
#1 /home/eikonaph/public_html/wp-includes/plugin.php(212): WP_Hook->apply_filters(false, Array)
#2 /home/eikonaph/public_html/wp-includes/post-template.php(854): apply_filters('post_password_r...', false, NULL)
#3 /home/eikonaph/public_html/wp-content/plugins/wordpress-seo-premium/vendor/yoast/wordpress-seo/src/presentations/indexable-post-type-presentation.php(203): post_password_required()
#4 /home/eikonaph/public_html/wp-content/plugins/wordpress-seo-premium/vendor/yoast/wordpress-seo/src/presentations/abstract-presentation.php(64): Yoast\WP\SEO\Presentations\Indexable in /home/eikonaph/public_html/wp-content/plugins/sensei-lms/includes/class-sensei-posttypes.php on line 174

It seem completely unrelated, but most likely the error is preventing the server to respond to the request (I do not have the details of the exact printful request)

Disabling sensei fixed the issue, but I would like to enable it again and I think this error may affect other functionalities as well.

PHP version: 7.3 sensei version: 3.8.1

Thanks for having a look

jom commented 3 years ago

Duplicate of #4005 ; Fixed by #4006 (3.9.0)