10/22/2015 at 7:46 pm
#351482
Guest
The problem with the code:
if ( ! is_object( $post ) || $wp_query->post->ID != $id || ! self::$filterPermalink ) return $title;
is that you check for $post NOT being an object THEN you access $wp_query->post->ID.
However if $post is an object but $wp_query->post is not set then $wp_query->post->ID will fail, because your $post check is no protection against the illegal access.
This is safer and more sensible:
if ( ! set( $wp_query->post->ID ) || $wp_query->post->ID != $id || ! self::$filterPermalink ) return $title;
The problem only ever seems to occur for a 404 anyway, so the is_404() check like we said is another double check.
