Skip to content

Commit

Permalink
Fix form deletion - do not use %d for form_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Feb 23, 2025
1 parent 8ca482d commit fac1b95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .tests/php/unit/Settings/FormsPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ public function test_delete_events(): void {
'formId' => '177',
],
];
$where_clause = '(source = %s AND form_id = %d) OR (source = %s AND form_id = %d)';
$where_clause = '(source = %s AND form_id = %s) OR (source = %s AND form_id = %s)';
$prefix = 'wp_';
$table_name = 'hcaptcha_events';
$sql = "DELETE FROM $prefix$table_name WHERE $where_clause";
$prepared = "DELETE FROM $prefix$table_name WHERE (source = '[\"WordPress\"]' AND form_id = 'login') OR (source = '[\"Contact Form 7\"]' AND form_id = 177)";
$prepared = "DELETE FROM $prefix$table_name WHERE (source = '[\"WordPress\"]' AND form_id = 'login') OR (source = '[\"Contact Form 7\"]' AND form_id = '177')";
$result = count( $ids );

// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
Expand Down
2 changes: 1 addition & 1 deletion src/php/Settings/FormsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected function delete_events( array $ids ): bool {
$values = [];

foreach ( $ids as $item ) {
$conditions[] = '(source = %s AND form_id = %d)';
$conditions[] = '(source = %s AND form_id = %s)';
$values[] = $item['source'];
$values[] = $item['formId'];
}
Expand Down

0 comments on commit fac1b95

Please sign in to comment.