sensei icon indicating copy to clipboard operation
sensei copied to clipboard

Critical error Uncaught TypeError: Sensei_Assets::get_icon()

Open naveenrnimmala opened this issue 1 year ago • 4 comments

This is from woocommerce status logs. Am getting critical errors during course browsing.

Uncaught TypeError: Sensei_Assets::get_icon(): Argument #1 ($name) must be of type string, null given, called in /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php on line 283 and defined in /home/public_html/wp-content/plugins/sensei-lms/includes/class-sensei-assets.php:310 CONTEXT: {"error":{"type":1,"file":"/home/public_html/wp-content/plugins/sensei-lms/includes/class-sensei-assets.php","line":310},"backtrace":["","#0 /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(283): Sensei_Assets->get_icon()","#1 /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(266): Sensei\Blocks\Course_Theme\Course_Navigation->lesson_status_icon()","#2 /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(168): Sensei\Blocks\Course_Theme\Course_Navigation->render_lesson()","#3 [internal function]: Sensei\Blocks\Course_Theme\Course_Navigation->Sensei\Blocks\Course_Theme\{closure}()","#4 /home/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(166): array_map()","#5 /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(100): Sensei\Blocks\Course_Theme\Course_Navigation->render_module()","#6 [internal function]: Sensei\Blocks\Course_Theme\Course_Navigation->Sensei\Blocks\Course_Theme\{closure}()","#7 /home/public_html/wp-content/plugins/sensei-lms/includes/blocks/course-theme/class-course-navigation.php(97): array_map()","#8 /home/public_html/wp-includes/class-wp-block.php(463): Sensei\Blocks\Course_Theme\Course_Navigation->render_course_navigation()","#9 /home/public_html/wp-includes/class-wp-block.php(443): WP_Block->render()","#10 /home/public_html/wp-includes/class-wp-block.php(443): WP_Block->render()","#11 /home/public_html/wp-includes/blocks.php(1705): WP_Block->render()","#12 /home/public_html/wp-includes/blocks.php(1743): render_block()","#13 /home/public_html/wp-includes/block-template.php(263): do_blocks()","#14 /home/public_html/wp-includes/template-canvas.php(12): get_the_block_template_html()","#15 /home/public_html/wp-includes/template-loader.php(106): include('/home/u76042662...')","#16 /home/public_html/wp-blog-header.php(19): require_once('/home/u76042662...')","#17 /home\/public_html/index.php(17): require('/home/u76042662...')","#18 {main}","thrown"]}

PHP / WordPress / Sensei LMS version

WP 6.5.2 PHP 8.2.13 Sensei 4.23.1

Browser / OS version

Screenshot / Video

Context / Source

naveenrnimmala avatar Apr 19 '24 06:04 naveenrnimmala

Hi @naveenrnimmala!

Could you help us to reproduce the issue by adding the testing instructions?

Ideally, we need the whole path from the course creation to the student activity that was before and at the moment of the issue happened.

Please, be as detailed as possible and consider attaching screenshots or video whenever you think it might help.

Thank you!

merkushin avatar Apr 23 '24 15:04 merkushin

Did some testing with HPPS enabled as I was suspicious, but that doesn't appear to be the culprit.

@naveenrnimmala @cskindley Do you have Sensei installed on a WordPress.com site or a self-hosted site?

donnapep avatar May 29 '24 19:05 donnapep

Self hosted. It was a foobarred installation of the TTF default theme.It was a theme issue I fixed by reinstalling. BUT the culprit is an “invalid json response” when trying to add pages via the editor.What really needs to happen is the automattic theme devs need a master reset for FSE default themes because just uninstalling and reinstalling does not remove it’s db entries.Scott @.*** May 29, 2024, at 3:24 PM, Donna Peplinskie @.***> wrote: Did some testing with HPPS enabled as I was suspicious, but that doesn't appear to be the culprit. @naveenrnimmala @cskindley Do you have Sensei installed on a WordPress.com site or a self-hosted site?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cskindley avatar May 29 '24 19:05 cskindley

My team found the issue: wp-content/plugins/sensei-lms/assets/course-theme/blocks/lesson-blocks/module-title/block.json

Line 6 is missing the type attribute:

 {
   "type": "string",
   "default": "some-className"
    }

And the entire block needs a title: after line 31 (35 after the above fix):

"title": "Lesson Module"

Brad-Lewter avatar Aug 09 '24 14:08 Brad-Lewter

My team found the issue: wp-content/plugins/sensei-lms/assets/course-theme/blocks/lesson-blocks/module-title/block.json

Line 6 is missing the type attribute:

 {
   "type": "string",
   "default": "some-className"
    }

And the entire block needs a title: after line 31 (35 after the above fix):

"title": "Lesson Module"

Thank you so much. I was almost planning to redo my site with another LMS.

naveenrnimmala avatar Aug 10 '24 09:08 naveenrnimmala

Sharing what I've found so far...

I still haven't been able to reproduce this issue, and I'm not seeing how this could have anything to do with it. I will admit though that that is incorrectly formatted block JSON, which I'll resolve in a separate issue.

While trying to debug this further, I noticed in the log file provided here that complete was passed to the lesson_status_icon function. Subsequently calling self::ICONS[ $status ] would find no match in the ICONS array, thereby triggering the error.

Although it's unclear how to arrive in a state where complete is specified instead of completed, this can be fixed by adding a new entry to the ICONS array for the complete key.

I'll open a PR for this soon.

donnapep avatar Aug 15 '24 22:08 donnapep