Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function add_admin_class( $classes ) {
if ( empty( $page ) || $page === 'formidable' ) {
$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );

if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) {
if ( in_array( $action, array( 'settings', 'edit', 'list' ), true ) ) {
$page .= $action;
} else {
$page = $action;
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmFormActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static function show_action_icon_link( $action_control, $allowed ) {

$default_shown = array( 'wppost', 'register', 'payment', 'quiz', 'hubspot' );
$default_shown = array_values( array_diff( $default_shown, $allowed ) );
$default_position = array_search( $action_control->id_base, $default_shown );
$default_position = array_search( $action_control->id_base, $default_shown, true );
$allowed_count = count( $allowed );

if ( isset( $action_control->action_options['active'] ) && $action_control->action_options['active'] ) {
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmTestModeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static function should_show_upsell() {
return false;
}

return ! in_array( FrmAddonsController::license_type(), array( 'plus', 'business', 'elite' ) );
return ! in_array( FrmAddonsController::license_type(), array( 'plus', 'business', 'elite' ), true );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4426,7 +4426,7 @@ private static function get_images_dropdown_option_html_attrs( $option, $args )
$html_attrs_arr = array();

foreach ( $option['custom_attrs'] as $key => $value ) {
if ( in_array( $key, array( 'type', 'class', 'data-value' ) ) ) {
if ( in_array( $key, array( 'type', 'class', 'data-value' ), true ) ) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/helpers/FrmFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ private static function form_has_top_labels( $form ) {
private static function field_has_top_label( $field, $form ) {
$label_position = FrmFieldsHelper::label_position( $field['label'], $field, $form );

return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
return in_array( $label_position, array( 'top', 'inside', 'hidden' ), true );
}

/**
Expand Down
8 changes: 4 additions & 4 deletions classes/models/FrmEntryFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ protected function add_row_for_standard_field( $field_value, &$content ) {
protected function add_html_row_for_included_extra( $field_value, &$content ) {
$this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );

if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
$this->add_single_cell_html_row( $display_value, $content );
} else {
$value_args = $this->package_value_args( $field_value );
Expand All @@ -688,7 +688,7 @@ protected function add_html_row_for_included_extra( $field_value, &$content ) {
protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
$this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );

if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
$this->add_single_value_plain_text_row( $display_value, $content );
} else {
$this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
Expand Down Expand Up @@ -862,7 +862,7 @@ protected function include_field_in_content( $field_value ) {
* @return bool
*/
protected function is_extra_field( $field_value ) {
return in_array( $field_value->get_field_type(), $this->skip_fields() );
return in_array( $field_value->get_field_type(), $this->skip_fields(), true );
}

/**
Expand All @@ -875,7 +875,7 @@ protected function is_extra_field( $field_value ) {
* @return bool
*/
protected function is_extra_field_included( $field_value ) {
return in_array( $field_value->get_field_type(), $this->include_extras );
return in_array( $field_value->get_field_type(), $this->include_extras, true );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check if get_field_type() returns are compared with lowercase values consistently
# and verify case handling for field types across the codebase

# Find all field type definitions and usages
echo "=== Checking field type constant definitions ==="
rg -nP "const\s+.*FIELD.*TYPE.*=.*['\"]" --type=php -A 1

echo -e "\n=== Checking field type property assignments ==="
rg -nP "(->type|\\['type'\\])\s*=\s*['\"]" --type=php -C 2

echo -e "\n=== Checking get_field_type method implementations ==="
ast-grep --pattern 'function get_field_type($$$) { $$$ }'

echo -e "\n=== Checking other uses of include_extras ==="
rg -nP "include_extras" --type=php -C 3

Repository: Strategy11/formidable-forms

Length of output: 14980


🏁 Script executed:

# Find the context around line 878 in FrmEntryFormatter.php
sed -n '860,895p' classes/models/FrmEntryFormatter.php

# Search for get_field_type method implementations
rg -n "function get_field_type" --type=php -A 3

# Check FrmField class for get_field_type
rg -n "class FrmField" --type=php -A 50 | head -100

# Find where is_extra_field_included is called to understand $field_value parameter
rg -n "is_extra_field_included" --type=php -B 5 -A 2

Repository: Strategy11/formidable-forms

Length of output: 10794


🏁 Script executed:

# Find get_field_attr implementation in FrmFieldValue
sed -n '1,250p' classes/models/FrmFieldValue.php | grep -n "get_field_attr" -A 5

# Also check the broader FrmFieldValue class
rg -n "get_field_attr" classes/models/FrmFieldValue.php -A 5

# Check where field type comes from - look for field object structure
rg -n "->type\s*=" --type=php -B 2 -A 1 | head -50

# Check if there's any uppercase field type anywhere in the data flow
rg -n "type.*[A-Z]" --type=php | grep -i field | head -20

Repository: Strategy11/formidable-forms

Length of output: 6099


🏁 Script executed:

# Check FrmField class for field creation and type handling
sed -n '1,100p' classes/models/FrmField.php | head -100

# Look for field type normalization or constraints
rg -n "field.*type" classes/models/FrmField.php | grep -i "lower\|upper\|case\|normalize" | head -10

# Check database schema definitions
find . -name "*migrate*" -o -name "*database*" -o -name "*schema*" | grep -i php | head -10

# Look for field type assignments in the database/import code
rg -n "\['type'\]\s*=" --type=php classes/models/ -B 2 -A 1 | head -60

Repository: Strategy11/formidable-forms

Length of output: 4408


🏁 Script executed:

# Search for field creation and database migration code
find . -path ./node_modules -prune -o -name "*migrate*.php" -type f -print

# Check FrmMigrate and database related files
ls -la classes/models/FrmFormMigrator.php classes/models/FrmMigrate.php 2>/dev/null || echo "Files not found"

# Check if field type is ever validated or normalized during save
rg -n "function update\|function insert" classes/models/FrmField.php -A 10 | head -50

# Search for any place where field type is set to uppercase
rg -n "strtoupper.*type\|type.*strtoupper" --type=php | head -10

# Check how field types are used in comparisons throughout the code
rg -n "get_field_type()\s*==\|get_field_type()\s*===" --type=php | head -10

# Check all places where include_extras is used in comparisons
rg -n "in_array.*include_extras\|include_extras.*in_array" --type=php -B 2 -A 2

Repository: Strategy11/formidable-forms

Length of output: 235


🏁 Script executed:

# Check the FrmMigrate file for field type handling
grep -n "type" classes/models/FrmMigrate.php | grep -i "field\|strtolower\|lower" | head -20

# Check FrmFormMigrator for field type handling
grep -n "type" classes/models/FrmFormMigrator.php | head -30

# Look for database operations with field type
rg -n "INSERT INTO.*frm_fields\|UPDATE.*frm_fields" --type=php -B 2 -A 3 | head -50

# Check for any field type case sensitivity issues in tests
rg -n "get_field_type" tests/ --type=php -B 2 -A 2 | head -40

# Check skip_fields to understand what values it compares against
rg -n "skip_fields" classes/models/FrmEntryFormatter.php -B 5 -A 10

Repository: Strategy11/formidable-forms

Length of output: 5951


Case normalization needed for consistent field type comparison.

Line 878 uses strict comparison to check if get_field_type() matches values in include_extras, which is explicitly lowercased at line 324. However, get_field_type() returns the field type directly from the field object without case normalization. While field types throughout the codebase are currently lowercase, the code relies on this implicit assumption rather than enforcing it explicitly.

For safety and maintainability, either:

  1. Normalize the result of get_field_type() before comparison: strtolower( $field_value->get_field_type() )
  2. Add a comment documenting that field types are guaranteed to be lowercase
  3. Normalize field types at the point they're stored/retrieved

Note that the same pattern exists at line 865 in is_extra_field(), which compares against the hardcoded lowercase values in skip_fields().

🤖 Prompt for AI Agents
In @classes/models/FrmEntryFormatter.php at line 878, The comparison uses
get_field_type() against lowercased entries in include_extras but doesn't
normalize the field type; update the comparisons to use strtolower(
$field_value->get_field_type() ) (and similarly within is_extra_field()) so the
match is case-insensitive and robust, ensuring you call strtolower on the field
type before in_array checks against include_extras/skip_fields.

}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmEntryMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public static function search_entry_metas( $search, $field_id, $operator ) {
$where = '';

foreach ( $search as $field => $value ) {
if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ), true ) ) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions classes/models/FrmEntryShortcodeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function generate_content_for_all_fields() {
* @return string
*/
protected function generate_field_content( $field ) {
if ( in_array( $field->type, $this->skip_fields ) ) {
if ( in_array( $field->type, $this->skip_fields, true ) ) {
return '';
}

Expand Down Expand Up @@ -298,7 +298,7 @@ protected function generate_two_cell_shortcode_row( $field, $value = null ) {
* @return void
*/
protected function add_field_array( $field ) {
if ( in_array( $field->type, $this->skip_fields ) ) {
if ( in_array( $field->type, $this->skip_fields, true ) ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ public static function get_params( $form = null ) {
}
}

if ( in_array( $values['action'], array( 'create', 'update' ) ) &&
if ( in_array( $values['action'], array( 'create', 'update' ), true ) &&
( ! $_POST || ( ! isset( $_POST['action'] ) && ! isset( $_POST['frm_action'] ) ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
) {
$values['action'] = 'new';
Expand Down
2 changes: 1 addition & 1 deletion classes/views/frm-entries/sidebar-shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

<?php
foreach ( (array) $data as $k => $d ) {
if ( in_array( $k, array( 'browser', 'referrer', 'user_journey' ) ) ) {
if ( in_array( $k, array( 'browser', 'referrer', 'user_journey' ), true ) ) {
continue;
}
?>
Expand Down
2 changes: 1 addition & 1 deletion stripe/controllers/FrmTransLiteActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ function () use ( $entry_id, &$destroy_callback ) {
public static function before_save_settings( $settings, $action ) {
$settings['gateway'] = ! empty( $settings['gateway'] ) ? (array) $settings['gateway'] : array( 'stripe' );

if ( in_array( 'square', $settings['gateway'] ) ) {
if ( in_array( 'square', $settings['gateway'], true ) ) {
$currency = FrmSquareLiteConnectHelper::get_merchant_currency();

$settings['currency'] = false !== $currency ? strtolower( $currency ) : 'usd';
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/entries/test_FrmShowEntryShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ protected function get_expected_default_shortcodes( $type, $atts ) {

foreach ( $fields as $field ) {

if ( in_array( $field->type, array( 'html', 'captcha' ) ) ) {
if ( in_array( $field->type, array( 'html', 'captcha' ), true ) ) {
continue;
}

Expand Down Expand Up @@ -1107,7 +1107,7 @@ protected function expected_default_array( $atts ) {

foreach ( $fields as $field ) {

if ( in_array( $field->type, array( 'html', 'captcha' ) ) ) {
if ( in_array( $field->type, array( 'html', 'captcha' ), true ) ) {
continue;
}

Expand Down