• Resolved levihe

    (@levihe)


    I’m getting the following PHP error

    [Thu Feb 01 15:17:07.085468 2024] [fcgid:warn] [pid 1552] mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: Argument 1 passed to ISC_Public::get_thumbnail_source_string() must be of the type int, null given, called in /public_html/wp-content/plugins/image-source-control-isc/public/public.php on line 419 and defined in /public_html/wp-content/plugins/image-source-control-isc/public/public.php:910 [Thu Feb 01 15:17:07.085510 2024] [fcgid:warn] [pid 1552] [client 2600:8800:5b21:ac00:65bf:193c:b67a:57bd:57142] mod_fcgid: stderr: Stack trace: [Thu Feb 01 15:17:07.085514 2024] [fcgid:warn] [pid 1552] [client 2600:8800:5b21:ac00:65bf:193c:b67a:57bd:57142] mod_fcgid: stderr: #0 public_html/wp-content/plugins/image-source-control-isc/public/public.php(419): ISC_Public->get_thumbnail_source_string(NULL) [Thu Feb 01 15:17:07.085517 2024] [fcgid:warn] [pid 1552] [client 2600:8800:5b21:ac00:65bf:193c:b67a:57bd:57142] mod_fcgid: stderr: #1 public_html/wp-includes/class-wp-hook.php(326): ISC_Public->add_featured_image_source_to_excerpt_block(‘<h4 style=”colo…’, Array) [Thu Feb 01 15:17:07.085521 2024] [fcgid:warn] [pid 1552] [client 2600:8800:5b21:ac00:65bf:193c:b67a:57bd:57142] mod_fcgid: stderr: #2 /public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(‘<h4 style=”colo…’, Array) [Thu Feb 01 15:17:07.085524 2024] [fcgid:warn] [pid 1552] [client 2600:8800:5b21:ac00:65bf:193c:b67a:57bd:57142] mod_fcgid: stderr: #3 /public_html/wp-includes/class-wp-block.php(293): apply_filters(‘render_block’, ‘<h4 style=”colo…’, Array, Obj in public_html/wp-content/plugins/image-source-control-isc/public/public.php on line 910

    Any ideas why?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Thomas Maier

    (@webzunft)

    Hi levihe,

    thanks for reaching out.

    I looked at the code in the plugin that is referenced here and can only guess that this is maybe related to new posts only. Is that possible?
    Anyway, I applied a potential fix. Please test this version and let me know if it works.

    Thomas

    Thread Starter levihe

    (@levihe)

    I’ve pinpointed a section of the code that might be contributing to the PHP Fatal error related to get_thumbnail_source_string(). The issue seems to occur when trying to access $post->ID immediately after calling get_post(), without verifying whether get_post() successfully returned a WP_Post object.

    Original code in public.php

    $post = get_post();
    return str_replace(
    '',
    $this->get_thumbnail_source_string( $post->ID ) . '',
    $block_content
    );



    Possible fix?

    $post = get_post();
    if ( $post instanceof WP_Post ) {
    return str_replace(
    '',
    $this->get_thumbnail_source_string( $post->ID ) . '',
    $block_content
    );
    } else {
    return $block_content; // Return the content unchanged if no valid post is found
    }


    I didn’t want to try it out on my live site, lol.

    Plugin Author Thomas Maier

    (@webzunft)

    ?? Thanks. That‘s about what I concluded and I added a similar check in my version. It is safe to test.

    Thread Starter levihe

    (@levihe)

    Awesome sauce! I didn’t see your response before posting what I found lol. Thanks for the super quick response and patched version.

    Plugin Author Thomas Maier

    (@webzunft)

    Thanks for the report!
    Happy to help. If you enjoy ISC, I would appreciate a positive review.

    Thanks,
    Thomas

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP error’ is closed to new replies.