[wp-trac] [WordPress Trac] #64472: PHP Warning: "continue" targeting switch in wp-admin/includes/upgrade.php line 3073

WordPress Trac noreply at wordpress.org
Fri Jan 2 14:37:57 UTC 2026


#64472: PHP Warning: "continue" targeting switch in wp-admin/includes/upgrade.php
line 3073
-----------------------------+-----------------------------
 Reporter:  phuochoit        |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  6.9
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 WordPress 6.9 triggers a PHP warning when running on PHP 7.3+ due to
 incorrect usage of `continue` statement within a `switch` block that is
 nested inside a `foreach` loop.
 ## Environment
 - **WordPress Version:** 6.9
 - **PHP Version:** 8.4.7 (also affects PHP 7.3+)
 - **File:** `wp-admin/includes/upgrade.php`
 - **Line:** 3073

 ## Error Message

 {{{
 PHP Warning: "continue" targeting switch is equivalent to "break".
 Did you mean to use "continue 2"? in /wp-admin/includes/upgrade.php on
 line 3073
 }}}


 ## Stack Trace

 {{{
 PHP Stack trace:
 PHP   1. {main}() /wp-admin/tools.php:0
 PHP   2. require_once() /wp-admin/tools.php:40
 PHP   3. require_once() /wp-admin/admin.php:35
 PHP   4. require_once() /wp-load.php:50
 PHP   5. require_once() /wp-config.php:107
 PHP   6. do_action($hook_name = 'init') /wp-settings.php:742
 PHP   7. WP_Hook->do_action($args = [0 => '']) /wp-includes/plugin.php:522
 PHP   8. WP_Hook->apply_filters($value = '', $args = [0 => '']) /wp-
 includes/class-wp-hook.php:365
 }}}


 ## Root Cause
 In `wp-admin/includes/upgrade.php`, starting at line 3018, there is a
 `foreach` loop that contains a `switch` statement (line 3028). At line
 3073, a `continue` statement is used within the `switch` block.

 ### Current Code Structure (lines 3018-3074):

 {{{
 php
 foreach ( $flds as $fld ) {
     // ... code ...

     switch ( $fieldname_lowercased ) {
         case '':
         case 'primary':
         case 'index':
         case 'fulltext':
         case 'unique':
         case 'key':
         case 'spatial':
             $validfield = false;

             // ... regex matching code ...

             // Skip if regex didn't match (malformed KEY definition).
             if ( empty( $index_matches['index_type'] ) ) {
                 continue;  // LINE 3073 - PROBLEMATIC
             }

             // ... more code ...

             break;  // LINE 3133
     }

     // ... code ...
 }
 }}}

 ## Problem Explanation
 Since PHP 7.3, using `continue` inside a `switch` statement is treated as
 equivalent to `break` (it only exits the switch, not the loop). This
 behavior change was introduced to prevent bugs and improve code clarity.

 The intent at line 3073 appears to be to skip to the next iteration of the
 `foreach` loop, not just exit the `switch` statement. Therefore, `continue
 2` should be used instead.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64472>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list