[wp-trac] [WordPress Trac] #44416: `compact()` will throw notice for undefined variables in PHP 7.3
WordPress Trac
noreply at wordpress.org
Fri Aug 10 20:04:11 UTC 2018
#44416: `compact()` will throw notice for undefined variables in PHP 7.3
-------------------------------------+---------------------
Reporter: desrosj | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.0
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-refresh | Focuses:
-------------------------------------+---------------------
Changes (by desrosj):
* keywords: needs-patch => has-patch needs-refresh
Comment:
[attachment:"44416.diff"] ensures that there are variable declarations for
each value being included in a `compact()` call with a few exceptions. The
main remaining notice is for `menu_order`. `menu_order` is checked for
`isset()` not `empty()` because it can be a `0`. Fixing this notice would
require more changes.
It also changes `wp_insert_post()` to use `array_keys()` on the list of
defaults instead of the passed `$postarr`, adds `ID` in (the variable is
`$post_ID` not `$ID`), and removes two field that are not present
(`$context` and `$filter`). This shouldn't change anything and should be
backwards compatible because the missing variables were not being
compacted anyway.
This is a more conservative approach, but not sure that I love it. All
tests are passing, but I have not checked if this is due to an absence of
test cases that would catch breaking changes, or because the tests
actually continue to pass.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44416#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list