[wp-trac] [WordPress Trac] #41524: Remove usage of each() from WP_Upgrader
WordPress Trac
noreply at wordpress.org
Tue Aug 1 23:32:54 UTC 2017
#41524: Remove usage of each() from WP_Upgrader
-----------------------------+-------------------------
Reporter: johnbillion | Owner:
Type: task (blessed) | Status: new
Priority: normal | Milestone: 4.9
Component: Upgrade/Install | Version:
Severity: major | Keywords: needs-patch
Focuses: |
-----------------------------+-------------------------
Ticket split out from #40109.
`WP_Upgrader::clear_destination()` uses `each()`, which is deprecated in
PHP 7.2 and therefore should be removed.
The `each()` function exhibits two pieces of behaviour which mean it can't
simply be replaced with `foreach()`:
1. After `each()` has executed, the array cursor will be left on the next
element of the array, or past the last element if it hits the end of the
array. This means you can break out of an each loop, and continue the
iteration at a later point. `Text_Diff_Engine_native::_diag()` does just
this.
2. With the `while ( each( $array ) )` pattern, it's possible to alter the
elements in the array during iteration. `WP_Upgrader::clear_destination()`
does this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41524>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list