@@ -1131,17 +1131,19 @@ private function execute_delete_statement( WP_Parser_Node $node ): void {
1131
1131
1132
1132
// 4. Execute DELETE statements for each table.
1133
1133
$ rows = 0 ;
1134
- foreach ( $ table_aliases as $ table ) {
1135
- $ this ->execute_sqlite_query (
1136
- sprintf (
1137
- 'DELETE FROM %s AS %s WHERE rowid IN ( %s ) ' ,
1138
- $ this ->quote_sqlite_identifier ( $ alias_map [ $ table ] ),
1139
- $ this ->quote_sqlite_identifier ( $ table ),
1140
- implode ( ', ' , array_column ( $ ids , "{$ table }_rowid " ) )
1141
- )
1142
- );
1143
- $ this ->set_result_from_affected_rows ();
1144
- $ rows += $ this ->affected_rows ;
1134
+ if ( count ( $ ids ) > 0 ) {
1135
+ foreach ( $ table_aliases as $ table ) {
1136
+ $ this ->execute_sqlite_query (
1137
+ sprintf (
1138
+ 'DELETE FROM %s AS %s WHERE rowid IN ( %s ) ' ,
1139
+ $ this ->quote_sqlite_identifier ( $ alias_map [ $ table ] ),
1140
+ $ this ->quote_sqlite_identifier ( $ table ),
1141
+ implode ( ', ' , array_column ( $ ids , "{$ table }_rowid " ) )
1142
+ )
1143
+ );
1144
+ $ this ->set_result_from_affected_rows ();
1145
+ $ rows += $ this ->affected_rows ;
1146
+ }
1145
1147
}
1146
1148
1147
1149
$ this ->set_result_from_affected_rows ( $ rows );
0 commit comments