• Resolved bluecap

    (@bluecap)


    Hi, I’m testing an upgrade from PHP 7.4 to PHP 8.1 and after upgrading, I’ve started getting a fatal error on the front page of courses (/course/[course-name]). The error is:

    2022/12/21 14:35:22 [error] 31782#31782: *830 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, non-static method Sensei_Course::course_image() cannot be called statically in [path]/wp-includes/class-wp-hook.php:308
    Stack trace:
    
    0 [path]/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
    
    1 [path]/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    
    2 [path]/wp-content/plugins/sensei-lms/templates/single-course.php(35): do_action('sensei_single_c…', 6181)
    
    3 [path]/wp-includes/template-loader.php(106): include('[path]…')
    
    4 [path]/wp-blog-header.php(19): require_once('[path]_…')
    
    5 [path]/index.php(17): require('[path]_…')
    
    6 {main}
    
    thrown in [path]/wp-includes/class-wp-hook.php on line 308"
    

    I’m using the free version of Sensei LMS and this error persists after upgrading to the newest version, 4.9.1 as of this writing. It seems that this error is happening in a core file of the Sensei LMS plugin and affects only PHP 8+.

    Could you please let me know if there is a fix available for this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Giannis (a11n)

    (@gikaragia)

    Hello @bluecap,

    we have tried to reproduce this error but we weren’t able to. Moreover, I inspected Sensei’s code and couldn’t find anything that would cause this error. This means that this is probably triggered by a customisation in your installation.

    In this error, PHP complains that function course_image is called statically while it is not a static method. To further debug the issue you should look for occurrences of something like this in any customizations that your site has:

    add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Course', 'course_image') ...

    Once you find this you should change it to:

    add_action( 'sensei_single_course_content_inside_before', array( Sensei()->course, 'course_image' ) ...

    Hope that helps!

    Giannis

    Thread Starter bluecap

    (@bluecap)

    Thanks, I found a line resembling your example in the theme’s functions.php. Changing it to your suggested fix has resolved the error.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error on course page after PHP 8’ is closed to new replies.