[wp-trac] [WordPress Trac] #55523: Remove deprecation notice from get_the_excerpt
WordPress Trac
noreply at wordpress.org
Thu Nov 27 15:33:08 UTC 2025
#55523: Remove deprecation notice from get_the_excerpt
-------------------------------------+-----------------------------
Reporter: jamesglendenning | Owner: SirLouen
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version: 3.8.1
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: template
-------------------------------------+-----------------------------
Changes (by SirLouen):
* status: new => assigned
* focuses: => template
* owner: (none) => SirLouen
* version: 5.9.2 => 3.8.1
* milestone: Awaiting Review => Future Release
* keywords: close => has-patch needs-testing
* type: enhancement => defect (bug)
Comment:
This is a little old, so it's time to see if it's worth it to revive this
corpse (or at least to tweak it).
@jrf it seems in [36319] we actually added a massive BC change. It was
seriously unfortunate to add the new parameter keeping the same structure.
The weird thing is that they left the 2.3 message which is completely
inappropiate given this change coming from #4439
The `bool` check is not enough (nor the deprecation message). It's
signaling something incomplete.
We have to track the history of `get_the_excerpt` to understand that
originally it was receiving a parameter that with time was removed, ending
with a useless parameter that got deprecated. Receiving any parameter
triggered the message like: "you should not add any parameters" (with an
`empty` check).
Now things are entirely different: Here there is an intersection of two
elements: "The new parameter is only accepted, a WP_Post in any of its
forms". The rest, falls into the original use-case (the `$fakeit`
parameter), hence it's deprecated.
So as @jamesglendenning suggested, the `bool` check is limited, and an
enhanced check can perfectly take place here, to cover all instances not
being a `WP_Post` or equivalent. It will not cause any backwards
compatibility issue and it will keep the original intention of this
deprecation notice excluding just the new variable accepted scenarios
while keeping the spirit of the deprecation.
Instead of `bool` I would opt for:
{{{#!php
<?php
! is_null( $post ) && ! is_numeric( $post ) && ! ( $post instanceof
WP_Post )
}}}
Sending a patch with this
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55523#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list