• Resolved Gevorg

    (@gev0rg)


    Hello

    I would like to draw your attention to a PHP issue which you can consider fixing with the next update of your plugin.

    We have PHP v8.2.28 running on the web-server.
    WordPress v6.8.1 is installed.
    The FS Poster plugin is installed as version 7.1.9

    This is the error that occurred:

    [01-May-2025 07:14:18 UTC] PHP Fatal error:  Uncaught TypeError: FSPoster\App\Providers\WPPost\WPPostService::postMutation(): Argument #1 ($post) must be of type WP_Post, null given, called in /home/customer/www/trike-bike.com.au/public_html/wp-content/plugins/fs-poster/App/Providers/WPPost/WPPostService.php on line 123 and defined in /home/customer/www/trike-bike.com.au/public_html/wp-content/plugins/fs-poster/App/Providers/WPPost/WPPostService.php:126

    The problem would occur in the file WPPostService.php, in the following function definition:

    public static function postMutation ( WP_Post $post, $postStatusChanged, $postDateChanged, $postTermsChanged, ?WP_Post $postBeforeMutation = null )

    The problem is that at times null is given as the variable $post, when the function expects the variable $post to be of the type WP_Post.

    As a temporary solution I made the following change to this function definition:

    public static function postMutation ($postStatusChanged, $postDateChanged, $postTermsChanged, ?WP_Post $post = null, ?WP_Post $postBeforeMutation = null )

    Furthermore I added this within the function:

    if ($post === null)	return;

    I also adjusted the instances where this function is being called, because the order of variables changed…

    …this:

    self::postMutation( $wpPost, false, false, true );

    …changed to this:

    self::postMutation(false, false, true, $wpPost );

    …this:

    self::postMutation( $wpPost, true, true, false );

    …changed to this:

    self::postMutation(true, true, false, $wpPost );

    …and this:

    self::postMutation( $postAfter, $postStatusChanged, $postDateChanged, false, $postBefore );

    …changed to this:

    self::postMutation($postStatusChanged, $postDateChanged, false, $postAfter, $postBefore );

    You can make your own considerations how to fix this problem. It’s just necessary to take into account that at times null is passed as the variable $post to the function postMutation, and therefore this circumstance must be caught somehow.

    Currently, after having made these changes, the PHP fatal error no longer occurs, it seems that this solution is working.

    This topic is not a question. If you think this solution works with your plugin you can mark this topic as solved.

    Sincerely,
    Gevorg

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author fscode

    (@fscode)

    Hi there!

    Here is not meant for providing support for the Pro version.

    We would like to have an opportunity to investigate your feedback further. Could you create a support ticket at https://support.fs-code.com or contact us via email at [email protected] please? We’ll work with you to resolve any issues as quickly as possible.

    Best Regards,

    FS Poster Team

    Thread Starter Gevorg

    (@gev0rg)

    I am not asking for any support, I am trying to help you solve a problem. I posted a solution for you.

    Just read the topic, or forward it to someone who can read English, and let your team examine the solution I have posted here for you.

    Sincerely,
    Gevorg

    Plugin Author fscode

    (@fscode)

    Thanks for your feedback.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Fatal error … Uncaught TypeError … WP_Post …null given [Solved?]’ is closed to new replies.