#45018 closed defect (bug) (fixed)
Non-string needle parameters throw warning in PHP 7.3
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 5.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Menus | Keywords: | php73 has-patch |
Focuses: | Cc: |
Description
In PHP 7.3, a new warning was added when a non-string is passed as a needle to strpos()
, or another similar function (see the link for a full list).
String search functions usually operate on a string needle. However, if a non-string is passed, it will be converted to an integer and interpreted as an ASCII codepoint.
The warning will be removed in PHP 8 and the needle parameter will be changed to a string.
Currently, there is one test displaying this warning when tests are run on PHP 7.3.
Tests_Nav_Menu_Theme_Change::test_numerical_locations
stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
It's possible there are more instances, but this is the only one being exposed with tests.
Attachments (3)
Change History (17)
This ticket was mentioned in Slack in #core by jorbin. View the logs.
7 years ago
#5
@
7 years ago
- Keywords has-patch needs-testing added; needs-patch removed
45018.diff is the related code from https://github.com/WordPress/wordpress-develop/pull/28.
#6
@
7 years ago
@desrosj, @jorbin: Why is the new test in 45018.diff is set to fail? The same failure occurs if I run that test with the changes to src/wp-includes/nav-menu.php
reverted.
#7
@
7 years ago
Sorry, my second sentence didn't post in my comment for some reason. The test still needs work. I am working on that tomorrow.
#8
@
7 years ago
Alright, updated patch incoming. If only the test is added, it will pass on all versions of PHP except 7.3
. On 7.3
, it will throw the same warning the other test method was throwing. The additional changes in the patch fix the issue for both tests.
Here are a few builds:
I fell into a bit of a rabbit hole trying to figure out why the test was failing and realized it was due to funky behavior with numeric menu slugs. I have opened #45361 to better address that.
This should also be the last change preventing the 7.3
job from passing. I removed 7.3
from the allowed failures list in the Travis configuration in the new patch.
#12
@
6 years ago
- Keywords fixed-5.0 removed
- Resolution set to fixed
- Status changed from new to closed
Fixed by [44167].
5 years ago
#14
This was committed in https://core.trac.wordpress.org/changeset/43899.
I've started working on a patch and the progress can be seen on https://github.com/WordPress/wordpress-develop/pull/28