[wp-trac] [WordPress Trac] #55523: Remove deprecation notice from get_the_excerpt
WordPress Trac
noreply at wordpress.org
Wed Apr 20 09:38:35 UTC 2022
#55523: Remove deprecation notice from get_the_excerpt
-------------------------------+------------------------------
Reporter: jamesglendenning | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.9.2
Severity: normal | Resolution:
Keywords: close | Focuses:
-------------------------------+------------------------------
Comment (by jamesglendenning):
Replying to [comment:2 jrf]:
> Thanks for opening this ticket and your suggestion.
>
>
> > the deprecation notice is now just making noise
>
> The deprecation notice only makes "noise" when a boolean is passed to
the function, which indicates a dev-error. I'd say keep the deprecation
notice and fix the dev error instead.
On further investigation as to why this was being triggered, it looks like
we may have passed true/false to the function via a data sync.
Interestingly though, the following will still return the post excerpt of
the post you're on.
{{{#!php
<?php
get_the_excerpt(false)
get_the_excerpt(true)
}}}
On one hand it's telling you off & with the other it's handing you the
output. This assumption based logic may have led the developer to believe
the function was working as intended, if they had muted deprecation
warnings on their local machine.
Could the check be improved by checking for all types & returning empty if
an unexpected input is parsed?
{{{#!php
<?php
if ( null !== $post && is_bool( $post ) && ! ($post instanceof WP_Post) )
{
_deprecated_argument( __FUNCTION__, '2.3.0' );
return '';
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55523#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list