Skip to content

Commit 1c7687a

Browse files
committed
Fix unintended switch-case fallthroughs
1 parent 0f5b5be commit 1c7687a

1 file changed

Lines changed: 33 additions & 32 deletions

File tree

wp-includes/sqlite-ast/class-wp-sqlite-driver.php

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,21 +1017,22 @@ private function execute_mysql_query( WP_Parser_Node $node ): void {
10171017
private function execute_transaction_or_locking_statement( WP_Parser_Node $node ): void {
10181018
$subnode = $node->get_first_child_node();
10191019
$token = $node->get_first_descendant_token();
1020+
10201021
switch ( $subnode->rule_name ) {
10211022
case 'transactionStatement':
10221023
// START TRANSACTION.
10231024
if ( WP_MySQL_Lexer::START_SYMBOL === $token->id ) {
10241025
$this->begin_transaction();
1025-
break;
1026+
return;
10261027
}
10271028

10281029
// COMMIT.
10291030
if ( WP_MySQL_Lexer::COMMIT_SYMBOL === $token->id ) {
10301031
$this->commit();
1031-
break;
1032+
return;
10321033
}
10331034

1034-
// Unknown statement. Fall through to the default case.
1035+
break;
10351036
case 'savepointStatement':
10361037
$savepoint_name = $this->translate( $subnode->get_first_child_node( 'identifier' ) );
10371038

@@ -1042,22 +1043,22 @@ private function execute_transaction_or_locking_statement( WP_Parser_Node $node
10421043
} else {
10431044
$this->execute_sqlite_query( sprintf( 'ROLLBACK TO SAVEPOINT %s', $savepoint_name ) );
10441045
}
1045-
break;
1046+
return;
10461047
}
10471048

10481049
// SAVEPOINT.
10491050
if ( WP_MySQL_Lexer::SAVEPOINT_SYMBOL === $token->id ) {
10501051
$this->execute_sqlite_query( sprintf( 'SAVEPOINT %s', $savepoint_name ) );
1051-
break;
1052+
return;
10521053
}
10531054

10541055
// RELEASE SAVEPOINT.
10551056
if ( WP_MySQL_Lexer::RELEASE_SYMBOL === $token->id ) {
10561057
$this->execute_sqlite_query( sprintf( 'RELEASE SAVEPOINT %s', $savepoint_name ) );
1057-
break;
1058+
return;
10581059
}
10591060

1060-
// Unknown statement. Fall through to the default case.
1061+
break;
10611062
case 'lockStatement':
10621063
// LOCK TABLE/LOCK TABLES.
10631064
if (
@@ -1092,7 +1093,7 @@ private function execute_transaction_or_locking_statement( WP_Parser_Node $node
10921093
$this->begin_transaction();
10931094
$this->table_lock_active = true;
10941095
}
1095-
break;
1096+
return;
10961097
}
10971098

10981099
// UNLOCK TABLES/UNLOCK TABLE.
@@ -1108,19 +1109,19 @@ private function execute_transaction_or_locking_statement( WP_Parser_Node $node
11081109
$this->commit();
11091110
$this->table_lock_active = false;
11101111
}
1111-
break;
1112+
return;
11121113
}
11131114

1114-
// Unknown statement. Fall through to the default case.
1115-
default:
1116-
throw $this->new_not_supported_exception(
1117-
sprintf(
1118-
'statement type: "%s" > "%s"',
1119-
$node->rule_name,
1120-
$subnode->rule_name
1121-
)
1122-
);
1115+
break;
11231116
}
1117+
1118+
throw $this->new_not_supported_exception(
1119+
sprintf(
1120+
'statement type: "%s" > "%s"',
1121+
$node->rule_name,
1122+
$subnode->rule_name
1123+
)
1124+
);
11241125
}
11251126

11261127
/**
@@ -1727,11 +1728,11 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
17271728
switch ( $keyword1->id ) {
17281729
case WP_MySQL_Lexer::DATABASES_SYMBOL:
17291730
$this->execute_show_databases_statement( $node );
1730-
break;
1731+
return;
17311732
case WP_MySQL_Lexer::COLUMNS_SYMBOL:
17321733
case WP_MySQL_Lexer::FIELDS_SYMBOL:
17331734
$this->execute_show_columns_statement( $node );
1734-
break;
1735+
return;
17351736
case WP_MySQL_Lexer::CREATE_SYMBOL:
17361737
if ( WP_MySQL_Lexer::TABLE_SYMBOL === $keyword2->id ) {
17371738
$table_name = $this->unquote_sqlite_identifier(
@@ -1754,15 +1755,15 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
17541755
}
17551756
return;
17561757
}
1757-
// Fall through to default.
1758+
break;
17581759
case WP_MySQL_Lexer::INDEX_SYMBOL:
17591760
case WP_MySQL_Lexer::INDEXES_SYMBOL:
17601761
case WP_MySQL_Lexer::KEYS_SYMBOL:
17611762
$table_name = $this->unquote_sqlite_identifier(
17621763
$this->translate( $node->get_first_child_node( 'tableRef' ) )
17631764
);
17641765
$this->execute_show_index_statement( $table_name );
1765-
break;
1766+
return;
17661767
case WP_MySQL_Lexer::GRANTS_SYMBOL:
17671768
$this->set_results_from_fetched_data(
17681769
array(
@@ -1774,22 +1775,22 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
17741775
return;
17751776
case WP_MySQL_Lexer::TABLE_SYMBOL:
17761777
$this->execute_show_table_status_statement( $node );
1777-
break;
1778+
return;
17781779
case WP_MySQL_Lexer::TABLES_SYMBOL:
17791780
$this->execute_show_tables_statement( $node );
1780-
break;
1781+
return;
17811782
case WP_MySQL_Lexer::VARIABLES_SYMBOL:
17821783
$this->last_result = true;
17831784
return;
1784-
default:
1785-
throw $this->new_not_supported_exception(
1786-
sprintf(
1787-
'statement type: "%s" > "%s"',
1788-
$node->rule_name,
1789-
$keyword1->get_value()
1790-
)
1791-
);
17921785
}
1786+
1787+
throw $this->new_not_supported_exception(
1788+
sprintf(
1789+
'statement type: "%s" > "%s"',
1790+
$node->rule_name,
1791+
$keyword1->get_value()
1792+
)
1793+
);
17931794
}
17941795

17951796
/**

0 commit comments

Comments
 (0)