[wp-trac] [WordPress Trac] #56982: Empty ELSE statement

WordPress Trac noreply at wordpress.org
Thu Nov 3 14:07:19 UTC 2022


#56982: Empty ELSE statement
-----------------------------+-------------------------------
 Reporter:  krunal265        |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Upgrade/Install  |     Version:  1.5
 Severity:  major            |  Resolution:
 Keywords:                   |     Focuses:  coding-standards
-----------------------------+-------------------------------

Comment (by SergeyBiryukov):

 Hi there, welcome to WordPress Trac! Thanks for the ticket.

 Just to save some time for anyone looking at the ticket, this is what the
 [source:tags/6.1/src/wp-admin/includes/upgrade.php?marks=2749#L2737 code
 in question] looks like:
 {{{
 // Create a tablename index for an array ($cqueries) of queries.
 foreach ( $queries as $qry ) {
         if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) {
                 $cqueries[ trim( $matches[1], '`' ) ] = $qry;
                 $for_update[ $matches[1] ]            = 'Created table ' .
 $matches[1];
         } elseif ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches
 ) ) {
                 ...
         } else {
                 // Unrecognized query type.
         }
 }
 }}}

 Introduced in [1575]. I believe the purpose of the empty `else` statement
 is to provide a comment to clarify the case when the query type is not
 recognized. It adds some context, though does not seem to affect anything
 further in the function. Does anyone have a strong opinion on whether it
 should be kept or removed?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56982#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list