gocodebox / lifterlms

LifterLMS, a WordPress LMS Solution: Easily create, sell, and protect engaging online courses.
https://lifterlms.com
GNU General Public License v3.0
178 stars 134 forks source link

Dashboard has incorrect navigation link URLs #2739

Closed brianhogg closed 1 month ago

brianhogg commented 1 month ago

This infinite loops if you click on My Memberships, where you keep appending my-memberships onto the URL each click.

Reproduction Steps

  1. Create a course, enrol a student and have them get a grade
  2. Visit student Dashboard > My Grades
  3. Click on (say) "My Courses" in the navigation

Expected Behavior

Page loads without error

Actual Behavior

Fatal error below. URL is /dashboard/my-grades/my-courses/ instead of /dashboard/my-courses/

Error Messages / Logs

Fatal error: Uncaught Error: Call to a member function get() on null in /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/functions/llms.functions.templates.dashboard.php:715 Stack trace: #0 /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/functions/llms.functions.templates.dashboard.php(138): lifterlms_template_student_dashboard_my_grades() #1 /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/shortcodes/class.llms.shortcode.my.account.php(55): lifterlms_student_dashboard(Array) #2 /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/shortcodes/class.llms.shortcodes.php(201): LLMS_Shortcode_My_Account::output(Array) #3 /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/shortcodes/class.llms.shortcodes.php(295): LLMS_Shortcodes::shortcode_wrapper(Array, Array) #4 /Users/brianhogg/laravel/lifter2/wp-includes/shortcodes.php(434): LLMS_Shortcodes::my_account(Array, '', 'lifterlms_my_ac...') #5 [internal function]: do_shortcode_tag(Array) #6 /Users/brianhogg/laravel/lifter2/wp-includes/shortcodes.php(273): preg_replace_callback('/\\[(\\[?)(lifter...', 'do_shortcode_ta...', '[lifterlms_my_a...') #7 /Users/brianhogg/laravel/lifter2/wp-includes/class-wp-hook.php(324): do_shortcode('[lifterlms_my_a...') #8 /Users/brianhogg/laravel/lifter2/wp-includes/plugin.php(205): WP_Hook->apply_filters('[lifterlms_my_a...', Array) #9 /Users/brianhogg/laravel/lifter2/wp-includes/blocks/post-content.php(50): apply_filters('the_content', '[lifterlms_my_a...') #10 /Users/brianhogg/laravel/lifter2/wp-includes/class-wp-block.php(519): render_block_core_post_content(Array, '[lifterlms_my_a...', Object(WP_Block)) #11 /Users/brianhogg/laravel/lifter2/wp-includes/class-wp-block.php(499): WP_Block->render() #12 /Users/brianhogg/laravel/lifter2/wp-includes/blocks.php(2061): WP_Block->render() #13 /Users/brianhogg/laravel/lifter2/wp-includes/blocks.php(2113): render_block(Array) #14 /Users/brianhogg/laravel/lifter2/wp-includes/block-template.php(260): do_blocks('<!-- wp:templat...') #15 /Users/brianhogg/laravel/lifter2/wp-includes/template-canvas.php(12): get_the_block_template_html() #16 /Users/brianhogg/laravel/lifter2/wp-includes/template-loader.php(106): include('/Users/brianhog...') #17 /Users/brianhogg/laravel/lifter2/wp-blog-header.php(19): require_once('/Users/brianhog...') #18 /Users/brianhogg/laravel/lifter2/index.php(17): require('/Users/brianhog...') #19 /Users/brianhogg/.composer/vendor/laravel/valet/server.php(110): require('/Users/brianhog...') #20 {main} thrown in /Users/brianhogg/laravel/lifter2/wp-content/plugins/lifterlms/includes/functions/llms.functions.templates.dashboard.php on line 715

This issue has be recreated:

brianhogg commented 1 month ago

This seems to only be happening locally at the moment.

brianhogg commented 1 month ago

Branch to avoid fatal error on My grades if the course isn't found based on the slug to start. https://github.com/gocodebox/lifterlms/compare/fix/navigation?expand=1

brianhogg commented 1 month ago

The reason is the Dashboard page was not set in the LifterLMS settings.

brianhogg commented 1 month ago

Will look to add additional warnings about Dashboard page being set in the LifterLMS settings.