You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds usage tracking for chat-form and missing-addon test-mode views. Adds a frm_testmode_form_actions action hook to the enabled form actions container.
We reviewed changes in f0b2e9e...31d79d9 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@classes/controllers/FrmUsageController.php`:
- Line 18: The class constant declaration "private const FLOWS_ACTION_NAME" in
FrmUsageController causes a PHP 7.0 parse error because visibility on constants
is supported only from PHP 7.1; change the declaration to a plain const
FLOWS_ACTION_NAME (remove the "private" visibility) inside the
FrmUsageController class (or alternatively update project PHP requirement to
>=7.1), ensuring all references to FLOWS_ACTION_NAME continue to work.
The reason will be displayed to describe this comment to others. Learn more.
@Crabcyborg No. I meant we won't need to add a hook there, just check if ( $enabled ) { foreach ... }. Because that file contains many test mode add-ons code.
The reason will be displayed to describe this comment to others. Learn more.
Variable $form_actions might not be defined
A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@classes/controllers/FrmTestModeController.php`:
- Around line 99-100: Make the usage-counter update invoked by
FrmUsageController::update_flows_data concurrency-safe by replacing its separate
read/increment/write sequence with an atomic increment or concurrency-safe
storage operation. Preserve both view_test_mode call sites in
FrmTestModeController while ensuring concurrent events cannot overwrite each
other or undercount the counter.
- Around line 99-100: Update the test-mode tracking in FrmTestModeController
around render_testing_mode_container() so
FrmUsageController::update_flows_data() runs only for the initial preview
request, not AJAX error redraws or success renders. Use the existing request
context or preview-specific condition to gate the 'view_test_mode'/'chat_form'
update while preserving the container rendering behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
Push a commit to this branch (recommended)
Create a new PR with the fixes
ℹ️ Review info⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d05c1fed-a227-4066-b5b4-f84aab1dbe2f
📥 Commits
Reviewing files that changed from the base of the PR and between f0b2e9e and 31d79d9.
📒 Files selected for processing (3)
classes/controllers/FrmTestModeController.php
classes/controllers/FrmUsageController.php
classes/views/test-mode/container.php
🚧 Files skipped from review as they are similar to previous changes (2)
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Make usage-counter updates concurrency-safe.
At Lines [99-100] and [148-151], both new events use FrmUsageController::update_flows_data(). That method reads the flows option, increments the value, and writes it back in separate operations. Concurrent test-mode views can overwrite each other and undercount view_test_mode.
Update the counter atomically, or use storage that supports concurrent increments, before relying on these new call sites.
Also applies to: 148-151
🧰 Tools🪛 ast-grep (0.45.0)
[warning] 100-100: Avoid side effects in a file that defines symbols
Context: echo '
' . esc_html__( 'Test Mode is currently not supported for conversational forms.', 'formidable' ) . '
';
Note: [CWE-710] Improper Adherence to Coding Standards.
(no-side-effect)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@classes/controllers/FrmTestModeController.php` around lines 99 - 100, Make
the usage-counter update invoked by FrmUsageController::update_flows_data
concurrency-safe by replacing its separate read/increment/write sequence with an
atomic increment or concurrency-safe storage operation. Preserve both
view_test_mode call sites in FrmTestModeController while ensuring concurrent
events cannot overwrite each other or undercount the counter.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
#!/usr/bin/env bashset -euo pipefail
echo"== Show form and route relevant sections =="
rg -n \
-e "public static function show_form|public static function route|function get_form_shortcode" \
classes/controllers/FrmFormsController.php
sed -n '1980,2100p' classes/controllers/FrmFormsController.php
sed -n '2480,2545p' classes/controllers/FrmFormsController.php
echoecho"== Testmode JS references across tracked JS files only =="
python3 - <<'PY'import os, pathlib, repatterns = [re.compile(r'\btestmode\b'), re.compile(r'/testmode\b'), re.compile(r'frm_test_mode\b'), re.compile(r'frm_forms_preview\b')]for f in pathlib.Path('.').rglob('*'): if f.is_file() and f.suffix.lower() in {'.js','.jsx','.ts','.tsx'} and '.git' not in f.parts: try: text = f.read_text(encoding='utf-8') except Exception: continue if any(p.search(text) for p in patterns): print(f)PYechoecho"== Minimal deterministic filter call probe =="
python3 - <<'PY'# Reads the controller source and reports hook context around each apply_filter/add_filter call for frm_filter_final_form.from pathlib import Pathp = Path('classes/controllers/FrmFormsController.php')lines = p.read_text().splitlines()for i,l in enumerate(lines, 1): if 'frm_filter_final_form' in l: start=max(1,i-4); end=min(len(lines),i+4) print(f'--- lines {start}-{end} ---') for n in range(start,end+1): print(f'{n}: {lines[n-1]}')PY
Repository: Strategy11/formidable-forms
Length of output: 7116
🏁 Script executed:
#!/usr/bin/env bashset -euo pipefail
echo"== Testmode JS references with line numbers =="
python3 - <<'PY'import os, pathlib, resource_paths = [p for p in pathlib.Path('.').rglob('*') if p.is_file() and p.suffix.lower() in {'.js','.jsx','.ts','.tsx'} and '.git' not in p.parts]for f in source_paths: try: lines = f.read_text(encoding='utf-8').splitlines() except Exception: continue hits = [i for i,l in enumerate(lines, 1) if any(x in l for x in ('testmode','/testmode','frm_test_mode','frm_forms_preview'))] if hits: print(f'FILE: {f}') for i in hits: print(f'{i}: {lines[i-1]}')PYechoecho"== Full route/show_form call path around preview AJAX =="
sed -n '2159,2260p' classes/controllers/FrmFormsController.php
sed -n '2495,2555p' classes/controllers/FrmFormsController.php
Gate test-mode usage tracking to preview-only requests.
The frm_filter_final_form listener runs from show_form(), which is used by ajax preview, error redraws, and AJAX success returns. Those repeated AJAX renders also hit render_testing_mode_container() when testmode is present, so each render can increment view_test_mode. Track only the initial preview render, or gate the update by request context.
🧰 Tools🪛 ast-grep (0.45.0)
[warning] 100-100: Avoid side effects in a file that defines symbols
Context: echo '
' . esc_html__( 'Test Mode is currently not supported for conversational forms.', 'formidable' ) . '
';
Note: [CWE-710] Improper Adherence to Coding Standards.
(no-side-effect)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@classes/controllers/FrmTestModeController.php` around lines 99 - 100, Update
the test-mode tracking in FrmTestModeController around
render_testing_mode_container() so FrmUsageController::update_flows_data() runs
only for the initial preview request, not AJAX error redraws or success renders.
Use the existing request context or preview-specific condition to gate the
'view_test_mode'/'chat_form' update while preserving the container rendering
behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This tracks the number of times user views the test mode without the add-on installed and with the chat form.
This is tracked in the flows data with the format:
Summary by CodeRabbit