PHP Warning … Attempt to read property “post_status” on null [Solved?]
-
Hello
After having posted about the PHP fatal error issue, here is another PHP warning issue which occurs in the same file called
WPPostService.php.Again…
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 PHP warning hat occurred:
[04-May-2025 21:53:54 UTC] PHP Warning: Attempt to read property "post_status" on null in /home/customer/www/trike-bike.com.au/public_html/wp-content/plugins/fs-poster/App/Providers/WPPost/WPPostService.php on line 128It happens within the function called:
public static function postUpdated ( $wpPostId, $postAfter, $postBefore )If either
$postAfteror$postBeforeisnullthen trying to get->post_statusfromnullwill not work, and it causes the mentioned PHP warning; it happens here:$postStatusChanged = ScheduleService::getScheduleStatusByWpPostStatus( $postBefore->post_status ) != ScheduleService::getScheduleStatusByWpPostStatus( $postAfter->post_status );I applied this solution within the function:
if ($postAfter === null || $postBefore === null) return;If either one is
nullthe rest of the function is not executed.—
You can make your own consideration if this solution works with your plugin. One way or the other, you should take precaution for the case when
$postAfteror$postBeforecan benull.This topic is not a question. If you think this solution works with your plugin you can mark this topic as solved.
If you update your plugin with a solution to avoid this problem it will be appreciated.
Sincerely,
Gevorg
The topic ‘PHP Warning … Attempt to read property “post_status” on null [Solved?]’ is closed to new replies.