Opened 4 weeks ago
Last modified 6 days ago
#62070 new defect (bug)
PHP Deprecated warnings with null values for success and reject URLs
Reported by: | dhruvang21 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.6 |
Component: | Application Passwords | Keywords: | php-81 has-patch |
Focuses: | Cc: |
Description (last modified by )
If the $success_url
or $reject_url
are set to null
, then running esc_url()
on those for hidden inputs could produce PHP warnings.
PHP Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in /.../wp-includes/formatting.php on line 4482
Attachments (2)
Change History (8)
This ticket was mentioned in PR #7395 on WordPress/wordpress-develop by @dhruvang21.
4 weeks ago
#1
- Keywords has-patch added
#3
@
3 weeks ago
Hi @jrf,
I believe the error isn't caused by any plugin or theme, as I've tested it across multiple themes and without any plugins installed. The problem appears to arise from passing null instead of an empty string in the authorize-application.php file at line 70, which is the source of the issue.
To resolve this, I’ve attached a patch that changes null to an empty string, which fixes the error. If this patch looks appropriate, I’d be happy to commit the code.
Thanks!
#5
@
8 days ago
- Description modified (diff)
- Keywords has-patch added; close removed
- Summary changed from PHP 8.1 PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated to PHP Deprecated warnings with null values for success and reject URLs
- Version set to 5.6
Is switching from null
to an empty string good, or should it not print the hidden fields with an empty attribute if the success or reject URL is not defined?
@dhruvang21 Thanks for reporting this, however the proposed patch is not the way to go as you are hiding errors instead of fixing them.
The
esc_url()
function is clearly documented to only accept a string for the$url
parameter, so passing anything else is doing it wrong.These kind of issues need a backtrace and must be fixed at the source of the problem, i.e. the function call passing the incorrect data type. They should not be fixed in the receiving functions.
It is very likely that this error is caused by a plugin/theme, in which case: please report it there.