Opened 3 months ago
Closed 3 months ago
#64864 closed defect (bug) (fixed)
previous_posts(): PHP 8.1 deprecation notice
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | low |
| Severity: | trivial | Version: | |
| Component: | Themes | Keywords: | php81 has-patch has-unit-tests |
| Focuses: | coding-standards | Cc: |
Description
PHP 8.1 deprecation:
( ! ) Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in wp-includes/formatting.php on line 4487
This is caused by calling previous_posts( $display = FALSE ) devref on a singular page/post, as done by at least one plugin.
get_previous_posts_page_link() returns null, which is then passed to esc_url() in prevoous_posts().
Change History (3)
This ticket was mentioned in PR #11264 on WordPress/wordpress-develop by @alexodiy.
3 months ago
#1
- Keywords has-patch has-unit-tests added
Note: See
TracTickets for help on using
tickets.
This adds a null guard to
previous_posts(), matching the existing pattern used innext_posts()Without this check, calling
previous_posts()on a singular view can passnulltoesc_url(), which in turn triggers anltrim()deprecation notice on PHP 8.1 and newerProps
@dd32Fixes #64864