From 80f7919572b65645465168fdfec57ca8230983e5 Mon Sep 17 00:00:00 2001 From: Andrei Surdu Date: Mon, 23 Jun 2025 17:33:02 +0300 Subject: [PATCH] Fix -- PHP Warning: Attempt to read property "post_type" on string in .../custom-status.php on line 1476 Not sure when this is emitted, but sometimes I see this warning and it is flooding the logs. Probably the problem is somewhere else, or is not a problem at all, but this should mute this warning: ``` PHP Warning: Attempt to read property "post_type" on string in .../edit-flow/modules/custom-status/custom-status.php on line 1476 ``` --- modules/custom-status/custom-status.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index c76af258..5dff10c4 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -1472,6 +1472,10 @@ public function fix_preview_link_part_two( $permalink, $post, $sample ) { if ( is_int( $post ) ) $post = get_post( $post ); + // This might not be a valid post at all. + if ( ! is_object( $post ) || ! isset( $post->post_type ) ) + return $permalink; + //Should we be doing anything at all? if( !in_array( $post->post_type, $this->get_post_types_for_module( $this->module ) ) ) return $permalink;