Opened 7 years ago
Last modified 4 weeks ago
#41079 new defect (bug)
PHP Notice: Undefined offset: -1 in /var/www/html/live/wp-includes/rewrite.php
Reported by: | myrmidon16 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | Rewrite Rules | Keywords: | |
Focuses: | Cc: |
Description
Low priority, but I'm trying to reduce the size of my error logs, and this notice is a vast majority of it.
Issue lies at lines 376 & 378 in the "wp_resolve_numeric_slug_conflicts" function. Occurs when $postname_index is 0. With my limited understanding, it seems like that scenario can be skipped, so I added the below snippet to the "if" statement at line 363 in my build:
|| 0 === $postname_index
Please resolve in the next update. Thanks.
Change History (3)
#2
in reply to:
↑ 1
@
7 years ago
Replying to Presskopp:
array_search() only returns NULL if invalid parameters are passed to it. So the question is, why the parameters are invalid in your case. 2c
array_search() returns false if invalid parameters are passed to it. There is a gate at line 363 that checks for that, yet the result is getting past that.
Since $permastructs is the result of array_values(), it's safe to presume it is an indexed array. So if array_search() is not returning false, $postname_index is likely an index.
And since $permastructs[$postname_index - 1] at lines 376 & 378 are looking for an offset of -1, I presume $postname_index is 0.
array_search() only returns NULL if invalid parameters are passed to it. So the question is, why the parameters are invalid in your case. 2c