Make WordPress Core

Opened 2 weeks ago

Last modified 12 days ago

#44543 assigned defect (bug)

PHP 7.3 compatibility: using `continue` in `switch` statements

Reported by: jrf Owned by: jrf
Milestone: 5.0 Priority: normal
Severity: normal Version: trunk
Component: General Keywords: has-patch commit
Focuses: Cc:


As of PHP 7.3, using continue to target a switch control structure will throw an E_WARNING.

Applying continue to a switch is equivalent to using break and quite possibly, a continue targeting a higher level control structure is actually intended.

To target the higher level control structure, a numeric argument has to be passed to continue.


This change has been recently committed to PHP itself and will break the build against nightly for the current master already. See: https://travis-ci.org/WordPress/wordpress-develop/jobs/401538006#L828-L831.

The attached patch fixes the two instances of this in WordPress.


  • Both these switches are nested in other control structures, but end the switch at the scope closer of the outer control structure, so using break in these cases is equivalent to using continue 2.

FYI: The PHPCompatibility standard will include a sniff to detect this in the near future. This ticket is the result of some tests I've been running on the WIP PHPCompatibility sniff :wink:

Attachments (1)

patch-44543.patch (1.4 KB) - added by jrf 2 weeks ago.

Download all attachments as: .zip

Change History (3)

2 weeks ago

#1 @SergeyBiryukov
13 days ago

  • Milestone changed from Awaiting Review to 5.0

#2 @pento
12 days ago

  • Keywords commit added; 2nd-opinion removed
  • Owner set to jrf
  • Status changed from new to assigned

Patch looks good to me.

Note: See TracTickets for help on using tickets.