Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical error Uncaught TypeError: Sensei_Assets::get_icon() #7594

Closed
naveenrnimmala opened this issue Apr 19, 2024 · 7 comments · Fixed by #7667
Closed

Critical error Uncaught TypeError: Sensei_Assets::get_icon() #7594

naveenrnimmala opened this issue Apr 19, 2024 · 7 comments · Fixed by #7667
Milestone

Comments

@naveenrnimmala
Copy link

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

@merkushin
Copy link
Member

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!

@donnapep donnapep added [Status] Needs Author Reply Requires response from the author and removed [Status] Needs Triage Issue needs to be triaged labels Apr 23, 2024
@donnapep
Copy link
Collaborator

donnapep commented May 29, 2024

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?

@cskindley
Copy link

cskindley commented May 29, 2024 via email

@donnapep donnapep added [Status] Needs Triage Issue needs to be triaged and removed [Status] Needs Author Reply Requires response from the author labels Jul 16, 2024
@Brad-Lewter
Copy link

Brad-Lewter commented Aug 9, 2024

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"

@naveenrnimmala
Copy link
Author

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.

@donnapep
Copy link
Collaborator

donnapep commented Aug 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants