[wp-trac] [WordPress Trac] #44416: `compact()` will throw notice for undefined variables in PHP 7.3
WordPress Trac
noreply at wordpress.org
Wed Oct 3 20:12:17 UTC 2018
#44416: `compact()` will throw notice for undefined variables in PHP 7.3
-------------------------------------+-----------------------------
Reporter: desrosj | Owner: SergeyBiryukov
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 4.9.9
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+-----------------------------
Changes (by desrosj):
* keywords: has-patch needs-refresh => has-patch needs-testing
Comment:
Here is a breakdown of the two patches I just added:
[attachment:"44416-simple.diff"] is a more complete refresh of the
original approach, which changes less code and switches `compact()` to use
`array_keys()` on the default list provided to `wp_parse_args()`, ensuring
no custom keys passed cause notices.
[https://travis-ci.org/desrosj/wordpress-develop/builds/436815969 Here is
a build in Travis of this approach showing all warnings fixed] except the
one caused by #45018.
[attachment:"44416-wp_insert_post-rework.diff"] is a more complex rewrite
of `wp_insert_post()` that no longer creates a variable for each
individual post property (many of which were created just for the sake of
being present for `compact()`) and instead performs escaping and
sanitization and value correction to the original `$postarr` that is
passed to the function.
[https://travis-ci.org/desrosj/wordpress-develop/builds/436815768 Here is
a build in Travis of this approach showing all warnings fixed] except the
one caused by #45018.
Notes:
- Both patches apply identical fixes to all of the other files.
- The unit tests still need to be checked to verify the code being changed
in the patches has proper tests, or that the tests are still passing due
to a lack of tests.
I definitely like the simpler version of the patch for a minor release,
but think that the more complex patch could be considered for `5.0`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44416#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list