Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
539dfac
Use %i identifier placeholder in db queries
vivi-the-going-merry[bot] Sep 17, 2026
def7345
Merge remote-tracking branch 'origin/master' into use_wp_tablename_pl…
Crabcyborg Nov 18, 2026
ae26cac
Run the identifier placeholder sniff through the fixture harness
Crabcyborg Nov 19, 2026
505f648
fix(sniffs): preserve quoted table suffixes
Crabcyborg Nov 23, 2026
3c672ad
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Nov 23, 2026
9a312f5
Merge remote-tracking branch 'origin/master' into HEAD
Crabcyborg Nov 25, 2026
e2442a8
fix(sniffs): skip identifiers split across string parts
Crabcyborg Nov 25, 2026
86d4dd6
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Nov 25, 2026
cd008a8
Skip identifier placeholder fixes when the table name does not end cl…
Crabcyborg Nov 25, 2026
3094834
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Nov 26, 2026
a979bf3
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Nov 26, 2026
c236b1c
Merge remote-tracking branch 'origin/master' into HEAD
Crabcyborg Nov 27, 2026
44d79e8
Merge master into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Dec 1, 2026
fd652da
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Dec 1, 2026
7d22bc6
Merge origin/master into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Dec 1, 2026
f217098
Merge branch 'master' into use_wp_tablename_placeholder_in_db_queries
Crabcyborg Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/controllers/FrmWelcomeTourController.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private static function more_than_the_default_form_exists() {
*/
private static function check_for_form_embeds() {
global $wpdb;
$result = $wpdb->get_var( "SELECT 1 FROM {$wpdb->posts} WHERE post_content LIKE '%[formidable %' LIMIT 1" );
$result = $wpdb->get_var( $wpdb->prepare( 'SELECT 1 FROM %i WHERE post_content LIKE %s LIMIT 1', $wpdb->posts, '%[formidable %' ) );
return '1' === $result;
}

Expand Down
8 changes: 5 additions & 3 deletions classes/helpers/FrmEmailSummaryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,12 @@ public static function get_top_forms( $from_date, $to_date, $limit = 5 ) {

$result = $wpdb->get_results(
$wpdb->prepare(
"SELECT fr.id AS form_id, fr.name AS form_name, COUNT(*) as items_count
FROM {$wpdb->prefix}frm_items AS it INNER JOIN {$wpdb->prefix}frm_forms AS fr ON it.form_id = fr.id
'SELECT fr.id AS form_id, fr.name AS form_name, COUNT(*) as items_count
FROM %i AS it INNER JOIN %i AS fr ON it.form_id = fr.id
WHERE it.created_at BETWEEN %s AND %s AND it.is_draft = 0 AND parent_form_id = 0
GROUP BY form_id ORDER BY items_count DESC LIMIT %d",
GROUP BY form_id ORDER BY items_count DESC LIMIT %d',
$wpdb->prefix . 'frm_items',
$wpdb->prefix . 'frm_forms',
$from_date,
$to_date . ' 23:59:59',
$limit
Expand Down
3 changes: 1 addition & 2 deletions classes/models/FrmDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,7 @@ public static function cache_delete_group( $group ) {
public static function db_column_exists( $table, $column ) {
global $wpdb;

// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$result = $wpdb->get_results( $wpdb->prepare( 'SHOW COLUMNS FROM ' . $wpdb->prefix . $table . ' LIKE %s', $column ) );
$result = $wpdb->get_results( $wpdb->prepare( 'SHOW COLUMNS FROM %i LIKE %s', $wpdb->prefix . $table, $column ) );
return ! empty( $result );
}
}
4 changes: 2 additions & 2 deletions classes/models/FrmEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ public static function destroy( $id ) {
*/
do_action( 'frm_before_destroy_entry', $id, $entry );

$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) );
$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) );
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE item_id=%d', $wpdb->prefix . 'frm_item_metas', $id ) );
$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE id=%d', $wpdb->prefix . 'frm_items', $id ) );

self::clear_cache();

Expand Down
7 changes: 4 additions & 3 deletions classes/models/FrmEntryMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,14 @@ public static function update_entry_metas( $entry_id, $values ) {
'field_id' => $field_ids_to_remove,
);
FrmDb::get_where_clause_and_values( $where );
array_unshift( $where['values'], $wpdb->prefix . 'frm_item_metas' );

foreach ( $field_ids_to_remove as $field_id ) {
self::before_meta_change( $entry_id, $field_id );
}

// Delete any leftovers
$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, SlevomatCodingStandard.Files.LineLength.LineTooLong
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i ' . $where['where'], $where['values'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
self::clear_cache();

foreach ( $field_ids_to_remove as $field_id ) {
Expand Down Expand Up @@ -539,7 +540,7 @@ private static function meta_field_query( $field_id, $order, $limit, $args, arra
if ( is_numeric( $field_id ) ) {
$query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
} else {
$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
$query[] = $wpdb->prepare( 'LEFT JOIN %i fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $wpdb->prefix . 'frm_fields', $field_id );
}

if ( ! $args['is_draft'] ) {
Expand Down Expand Up @@ -843,7 +844,7 @@ public static function search_entry_metas( $search, $field_id, $operator ) {
$search = '%' . $search . '%';
}

$query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, SlevomatCodingStandard.Files.LineLength.LineTooLong
$query = $wpdb->prepare( "SELECT DISTINCT item_id FROM %i WHERE meta_value {$operator} %s and field_id = %d", $wpdb->prefix . 'frm_item_metas', $search, $field_id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, SlevomatCodingStandard.Files.LineLength.LineTooLong
}//end if

$results = $wpdb->get_col( $query, 0 ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
Expand Down
6 changes: 3 additions & 3 deletions classes/models/FrmField.php
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,9 @@ public static function destroy( $id ) {

self::delete_form_transient( $field->form_id );

$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) );
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE field_id=%d', $wpdb->prefix . 'frm_item_metas', $id ) );

$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
$result = $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE id=%d', $wpdb->prefix . 'frm_fields', $id ) );

if ( $result ) {
/**
Expand Down Expand Up @@ -1095,7 +1095,7 @@ public static function getOne( $id, $filter = false ) {
global $wpdb;

$where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s';
$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$query = $wpdb->prepare( 'SELECT * FROM %i WHERE ' . $where, $wpdb->prefix . 'frm_fields', $id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

$results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );

Expand Down
9 changes: 5 additions & 4 deletions classes/models/FrmForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,10 @@ public static function set_status( $id, $status ) {
'or' => 1,
);
FrmDb::get_where_clause_and_values( $where );
array_unshift( $where['values'], $status );
array_unshift( $where['values'], $wpdb->prefix . 'frm_forms', $status );

$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, SlevomatCodingStandard.Files.LineLength.LineTooLong
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE %i SET status = %s ' . $where['where'], $where['values'] ) );
} else {
$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
Expand Down Expand Up @@ -824,9 +825,9 @@ public static function destroy( $id ) {
}

// Disconnect the fields from this form
$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$wpdb->query( $wpdb->prepare( 'DELETE fi FROM %i AS fi LEFT JOIN %i fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $wpdb->prefix . 'frm_fields', $wpdb->prefix . 'frm_forms', $id, $id ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong

$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE id=%d OR parent_form_id=%d', $wpdb->prefix . 'frm_forms', $id, $id ) );

if ( ! $query_results ) {
return $query_results;
Expand Down
32 changes: 16 additions & 16 deletions classes/models/FrmMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,28 @@ private function add_composite_indexes() {
$index_name = 'idx_is_draft_created_at';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_is_draft_created_at ON `{$wpdb->prefix}frm_items` (is_draft, created_at)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_is_draft_created_at ON %i (is_draft, created_at)', $table_name ) );
}

$table_name = "{$wpdb->prefix}frm_item_metas";
$index_name = 'idx_field_id_item_id';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_field_id_item_id ON `{$wpdb->prefix}frm_item_metas` (field_id, item_id)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_field_id_item_id ON %i (field_id, item_id)', $table_name ) );
}

$table_name = "{$wpdb->prefix}frm_items";
$index_name = 'idx_form_id_is_draft';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_form_id_is_draft ON `{$wpdb->prefix}frm_items` (form_id, is_draft)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_form_id_is_draft ON %i (form_id, is_draft)', $table_name ) );
}

$table_name = "{$wpdb->prefix}frm_fields";
$index_name = 'idx_form_id_type';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_form_id_type ON `{$wpdb->prefix}frm_fields` (form_id, type(30))" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_form_id_type ON %i (form_id, type(30))', $table_name ) );
}

/**
Expand All @@ -340,7 +340,7 @@ private function add_composite_indexes() {
$index_name = 'idx_form_id_created_at';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_form_id_created_at ON `{$wpdb->prefix}frm_items` (form_id, created_at)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_form_id_created_at ON %i (form_id, created_at)', $table_name ) );
}

/**
Expand All @@ -351,14 +351,14 @@ private function add_composite_indexes() {
$index_name = 'idx_parent_form_id';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX idx_parent_form_id ON `{$wpdb->prefix}frm_forms` (parent_form_id)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX idx_parent_form_id ON %i (parent_form_id)', $table_name ) );
}

$table_name = "{$wpdb->prefix}frm_forms";
$index_name = 'frm_forms_template_status';

if ( ! self::index_exists( $table_name, $index_name ) ) {
$wpdb->query( "CREATE INDEX frm_forms_template_status ON `{$wpdb->prefix}frm_forms` (is_template, status, parent_form_id)" );
$wpdb->query( $wpdb->prepare( 'CREATE INDEX frm_forms_template_status ON %i (is_template, status, parent_form_id)', $table_name ) );
}
}

Expand Down Expand Up @@ -463,11 +463,11 @@ public function uninstall() {

global $wpdb, $wp_roles;

$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->gated_tokens ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $this->fields ) );
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $this->forms ) );
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $this->entries ) );
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $this->entry_metas ) );
$wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $this->gated_tokens ) );

delete_option( 'frm_options' );
delete_option( 'frm_db_version' );
Expand Down Expand Up @@ -499,7 +499,7 @@ public function uninstall() {
remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );

$post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM %i WHERE post_type in (%s, %s, %s)', $wpdb->posts, FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong

foreach ( $post_ids as $post_id ) {
// Delete's each post.
Expand All @@ -513,7 +513,7 @@ public function uninstall() {
delete_transient( 'frmpro_options' );
delete_transient( FrmOnboardingWizardController::TRANSIENT_NAME );

$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE option_name LIKE %s OR option_name LIKE %s', $wpdb->options, '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong

do_action( 'frm_after_uninstall' );

Expand Down Expand Up @@ -826,10 +826,10 @@ private function migrate_to_25() {
*/
private function migrate_to_23() {
global $wpdb;
$exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$exists = $wpdb->get_row( $wpdb->prepare( 'SHOW COLUMNS FROM %i LIKE %s', $this->forms, 'parent_form_id' ) );

if ( ! $exists ) {
$wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( $wpdb->prepare( 'ALTER TABLE %i ADD parent_form_id int(11) default 0', $this->forms ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
if ( ! $temp_styles ) {
global $wpdb;
// Make sure there wasn't a conflict with the query
$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$query = $wpdb->prepare( 'SELECT * FROM %i WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', $wpdb->posts, FrmStylesController::$post_type, 'publish' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
$temp_styles = FrmDb::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );

if ( ! $temp_styles ) {
Expand Down
Loading
Loading