• When trying to use this plugin on a site running PHP 8, a fatal error is thrown, a long with a whole bunch of warnings, for example:

    PHP Fatal error:  Uncaught TypeError: array_pop(): Argument #1 ($array) must be of type array, null given in /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php:468
    Stack trace:
    #0 /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php(468): array_pop(NULL)
    #1 /MY_SITE_ROOT/public_html/wp-includes/class-wp-hook.php(303): get_post_comments_callback('')
    #2 /MY_SITE_ROOT/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array)
    #3 /MY_SITE_ROOT/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Array)
    #4 /MY_SITE_ROOT/public_html/wp-admin/admin-ajax.php(187): do_action('wp_ajax_get_pos...')
    #5 {main}
      thrown in /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php on line 468
    PHP Warning:  Undefined variable $cls in /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php on line 408
    PHP Fatal error:  Uncaught TypeError: array_pop(): Argument #1 ($array) must be of type array, null given in /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php:468
    Stack trace:
    #0 /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php(468): array_pop(NULL)
    #1 /MY_SITE_ROOT/public_html/wp-includes/class-wp-hook.php(303): get_post_comments_callback('')
    #2 /MY_SITE_ROOT/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array)
    #3 /MY_SITE_ROOT/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Array)
    #4 /MY_SITE_ROOT/public_html/wp-admin/admin-ajax.php(187): do_action('wp_ajax_get_pos...')
    #5 {main}
      thrown in /MY_SITE_ROOT/public_html/wp-content/plugins/copy-or-move-comments/copy_move_comments.php on line 468
    PHP Warning:  Undefined array key "target_post_id" in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 80
    PHP Warning:  Undefined array key "source_post_id" in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 152
    PHP Warning:  Undefined array key "source_post_id" in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 191
    PHP Warning:  Undefined array key "target_post_id" in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 325
    PHP Warning:  Trying to access array offset on value of type null in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 338
    PHP Warning:  Undefined array key "move_comment_id" in /MY_SITE_ROOT/public_html/wp-content/plugins/move-comments/move-comments.php on line 267

    Basically, PHP 8 is a lot stricter about type safety, so you need to add some null-checks to make sure you don’t pass null into functions that expect arrays.

  • The topic ‘Throws fatal errors (and a bunch of warnings) on PHP 8’ is closed to new replies.