Skip to content

Give create-form the builder's defaults: anti-spam on and an email action - #3600

Merged
Crabcyborg merged 2 commits into
masterfrom
fix/issue-6859-create-form-defaults
Oct 22, 2026
Merged

Crabcyborg merged 2 commits into
masterfrom
fix/issue-6859-create-form-defaults

Conversation

@vivi-the-going-merry

@vivi-the-going-merry vivi-the-going-merry Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes Strategy11/formidable-pro#6859

Broken: forms made through the create-form ability had anti-spam off and no email action. Forms made in the builder get both.

Changed

  • FrmAbilitiesFormsController::execute_create_form() sets options[antispam] = 1 unless the caller passed options.antispam, so an explicit 0 stays off.
  • It then calls FrmFormsController::create_default_email_action(), skipped when is_template or parent_form_id is set. That method is now public instead of copied, and still runs the frm_create_default_email_action filter.
  • Builder code path is unchanged apart from the method's visibility.

Verified: Lite's local PHPUnit can't run here, so CI is the red/green. Test-only commit: the new defaults test failed on all 4 PHPUnit jobs (Anti-spam should be on by default, 0 is not 1). With the fix, all 4 pass, plus PHPCS, PHPStan, Psalm, Mago, Rector and PHP CS Fixer.

The other three new tests (explicit antispam = 0, template and child form skip, filter returning false) pass before and after; they guard the edges of the change. Not run end to end through an MCP client.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Strategy11/formidable-forms/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b64f2dd-3a9d-426c-b380-b6e519fbca5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@deepsource-io

deepsource-io Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 1927ae3...6f81b26 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Oct 21, 2026 2:30a.m. Review ↗
JavaScript Oct 21, 2026 2:30a.m. Review ↗

Important

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.

public function test_create_form_defaults_to_antispam_and_one_email_action() {
$created = $this->execute( 'create-form', array( 'name' => 'Form With Defaults' ) );

$this->assertNotWPError( $created );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertNotWPError()


The method you are trying to call is not defined, which can result in a fatal error.

$this->assertNotWPError( $created );

$form = FrmForm::getOne( $created['id'] );
$this->assertSame( 1, (int) ( $form->options['antispam'] ?? 0 ), 'Anti-spam should be on by default.' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


$form = FrmForm::getOne( $created['id'] );
$this->assertSame( 1, (int) ( $form->options['antispam'] ?? 0 ), 'Anti-spam should be on by default.' );
$this->assertCount( 1, FrmFormAction::get_action_for_form( $created['id'], 'email' ), 'The default email action should be created.' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertCount()


The method you are trying to call is not defined, which can result in a fatal error.

)
);

$this->assertNotWPError( $created );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertNotWPError()


The method you are trying to call is not defined, which can result in a fatal error.

$this->assertNotWPError( $created );

$form = FrmForm::getOne( $created['id'] );
$this->assertSame( 0, (int) ( $form->options['antispam'] ?? 1 ), 'An explicit antispam of 0 should be kept.' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

$this->assertCount( 0, FrmFormAction::get_action_for_form( $template['id'], 'email' ), 'A template should not get an email action.' );

$parent = $this->execute( 'create-form', array( 'name' => 'Parent Form' ) );
$this->assertNotWPError( $parent );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertNotWPError()


The method you are trying to call is not defined, which can result in a fatal error.

'parent_form_id' => $parent['id'],
)
);
$this->assertNotWPError( $child );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertNotWPError()


The method you are trying to call is not defined, which can result in a fatal error.

)
);
$this->assertNotWPError( $child );
$this->assertCount( 0, FrmFormAction::get_action_for_form( $child['id'], 'email' ), 'A child form should not get an email action.' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertCount()


The method you are trying to call is not defined, which can result in a fatal error.


remove_filter( 'frm_create_default_email_action', '__return_false' );

$this->assertNotWPError( $created );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertNotWPError()


The method you are trying to call is not defined, which can result in a fatal error.

remove_filter( 'frm_create_default_email_action', '__return_false' );

$this->assertNotWPError( $created );
$this->assertCount( 0, FrmFormAction::get_action_for_form( $created['id'], 'email' ), 'The filter should be able to stop the default email action.' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmAbilitiesFormsController::assertCount()


The method you are trying to call is not defined, which can result in a fatal error.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vivi-the-going-merry
vivi-the-going-merry Bot marked this pull request as ready for review October 21, 2026 02:36
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Oct 21, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

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.

Approve. create-form now matches the builder on both points the issue lists, and nothing else changed.

Reproduced live (Playground, Lite only), base vs this PR, calling execute_create_form() as an admin:

Input Base PR
no options antispam 0, 0 email actions antispam 1, 1 email action
options.antispam = 0 0, 0 actions 0 kept, 1 action
options.antispam = '0' '0', 0 actions '0' kept, 1 action
options.submit_value = 'Go' antispam 0 antispam 1, submit_value still 'Go'
is_template = 1 0 actions 0 actions
parent_form_id set 0 actions 0 actions

The test-only commit (53f3380) failed PHPUnit on 7.4 and the other jobs were cancelled behind it; at the head all four PHPUnit jobs, Psalm and the syntax checks pass. Source read: the builder (build_new_form()) sets antispam to 1 and calls the same create_default_email_action(), so this is the shared path, not a copy, and the frm_create_default_email_action filter still applies. Making the method public is the only builder-side change.

Not run: the filter-returning-false test locally (CI covers it), an MCP client end to end, Pro.

@franky-the-going-merry franky-the-going-merry Bot added vivi-pickup and removed franky-review franky-working Franky is actively reviewing this vivi-pickup labels Oct 21, 2026

@Crabcyborg Crabcyborg left a comment

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.

🚀

@Crabcyborg
Crabcyborg merged commit 59434e9 into master Oct 22, 2026
75 of 76 checks passed
@Crabcyborg
Crabcyborg deleted the fix/issue-6859-create-form-defaults branch October 22, 2026 12:59
@Crabcyborg Crabcyborg added this to the 7.1 milestone Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant