Skip to content

Add conversion from legacy PayPal actions to Commerce - #3686

Draft
Crabcyborg wants to merge 12 commits into
masterfrom
feat/paypal-legacy-migration
Draft

Crabcyborg wants to merge 12 commits into
masterfrom
feat/paypal-legacy-migration

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Offer conversion of legacy PayPal actions to PayPal Commerce from the action settings. Map payment amounts, subscriptions and conditions, disclose settings that cannot be copied exactly, and disable the legacy action after creating its replacement.

After Payment settings

Legacy "After Payment" rows (change a field when a payment completes or fails) now carry over to the new payment action in the same change_field format. Pro runs them for the Lite payment action since https://github.com/Strategy11/formidable-pro/pull/6978, and the Stripe add-on runs them while it is active. Incomplete rows are dropped.

When an action has these rows and neither can run them, the conversion is blocked. The notice asks to activate Formidable Pro, or to update it when the installed version is too old.

Notice design

The migration notice uses the existing Lite notice styles, with separate blocked (amber warning), error and success (green, with the list of settings to review) states.

Testing

  • Conversion regression tests: 7 tests and 23 assertions passed, including After Payment rows and the Pro requirement.
  • A conversion on the dev site carried both After Payment rows (Completed and Failed) to the new action and set the legacy action to draft.
  • The default, blocked, error and success states were checked in the browser with no console errors.
  • Scoped PHP syntax, PHPCS, Rector, PHP CS Fixer, Mago lint, ESLint, Oxlint and Stylelint passed. PHPStan is blocked by the duplicate wp_register_ability stub also present on unchanged master. Scoped Psalm only reports classes outside the scanned files.

Remaining draft validation

Run the migration against a connected sandbox account, including email triggers, subscription settings and a live After Payment field update. No live payment was attempted.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

@deepsource-io

deepsource-io Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in c90a8ed...cb4c203 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 Nov 23, 2026 9:02p.m. Review ↗
JavaScript Nov 23, 2026 9:02p.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.

$new_action->post_content = array_merge( $new_action->post_content, self::convert_settings( $legacy_settings, $form_id, $notes ) );

$action_array = (array) $new_action;
$new_action->post_content = apply_filters( 'frm_before_save_action', $new_action->post_content, $action_array, $action_array, array(), $payment_control );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 6 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.


$action_array = (array) $new_action;
$new_action->post_content = apply_filters( 'frm_before_save_action', $new_action->post_content, $action_array, $action_array, array(), $payment_control );
$new_action->post_content = apply_filters( 'frm_before_save_payment_action', $new_action->post_content, $action_array, $action_array, array(), $payment_control );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function apply_filters invoked with 6 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.

$button_attrs = array(
'type' => 'button',
'class' => 'button frm-button-primary frm-paypal-migrate-legacy',
'data-action-id' => (int) $form_action->ID,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $form_action 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.

'data-action-id' => (int) $form_action->ID,
);

if ( $blocker ) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $blocker 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.

1,
$notes
);
$this->assertSame( array( 'paypal' ), $value['gateway'], 'The gateway is PayPal Commerce.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

$this->assertSame( 2, $value['interval_count'], 'The billing interval count is preserved.' );
$this->assertSame( '12.50', $value['amount'], 'Fixed amounts are preserved.' );
$this->assertSame( 90, $value['trial_interval_count'], 'Month trials convert to days.' );
$this->assertCount( 2, $notes, 'Trial approximation and paid trial changes are disclosed.' );

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_FrmPayPalLiteLegacyMigration::assertCount()


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

1,
$notes
);
$this->assertSame( 'single', $value['type'], 'Donations become one-time payments.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

$notes
);
$this->assertSame( 'single', $value['type'], 'Donations become one-time payments.' );
$this->assertCount( 1, $notes, 'The donation conversion is disclosed.' );

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_FrmPayPalLiteLegacyMigration::assertCount()


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


public function test_invalid_actions_are_rejected() {
$result = FrmPayPalLiteLegacyMigrationHelper::migrate( 0 );
$this->assertWPError( $result, 'Missing actions are rejected before conversion.' );

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_FrmPayPalLiteLegacyMigration::assertWPError()


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

public function test_invalid_actions_are_rejected() {
$result = FrmPayPalLiteLegacyMigrationHelper::migrate( 0 );
$this->assertWPError( $result, 'Missing actions are rejected before conversion.' );
$this->assertSame( 'frm_paypal_invalid_action', $result->get_error_code(), 'The rejection identifies the invalid 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_FrmPayPalLiteLegacyMigration::assertSame()


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

Crabcyborg and others added 2 commits November 16, 2026 12:32
Legacy PayPal actions can change a field when a payment completes or
fails. These rows now carry over to the PayPal Commerce payment action,
which saves them in the same format. Pro runs them for the Lite payment
action, or the Stripe add-on runs them while it is active.

When an action has these rows and nothing can run them, the conversion
is blocked and the notice asks to activate or update Formidable Pro.

The migration notice now uses the Lite notice styles, with clear
blocked, error and success states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1,
$notes
);
$this->assertSame(

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_FrmPayPalLiteLegacyMigration::assertSame()


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

1,
$notes
);
$this->assertArrayNotHasKey( 'change_field', $value, 'Empty rows add no After Payment setting.' );

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_FrmPayPalLiteLegacyMigration::assertArrayNotHasKey()


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

$notes
);
$this->assertArrayNotHasKey( 'change_field', $value, 'Empty rows add no After Payment setting.' );
$this->assertSame( array(), $notes, 'Empty rows add no notes.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

}

public function test_after_payment_rows_need_a_supporting_pro_version() {
$this->assertFalse( is_callable( 'FrmProTransLiteController::change_fields_after_payment' ), 'This test needs Pro without After Payment support.' );

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_FrmPayPalLiteLegacyMigration::assertFalse()


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

),
);

$this->assertSame( '', $this->run_private_method( $method, array( array() ) ), 'Actions without After Payment rows can always convert.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

);

$this->assertSame( '', $this->run_private_method( $method, array( array() ) ), 'Actions without After Payment rows can always convert.' );
$this->assertStringContainsString( 'Activate Formidable Pro', $this->run_private_method( $method, array( $rows ) ), 'Without Pro, the conversion is blocked.' );

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_FrmPayPalLiteLegacyMigration::assertStringContainsString()


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

add_filter( 'frm_pro_installed', '__return_true' );
$blocker = $this->run_private_method( $method, array( $rows ) );
remove_filter( 'frm_pro_installed', '__return_true' );
$this->assertStringContainsString( 'Update Formidable Pro', $blocker, 'With an outdated Pro, the conversion asks for an update.' );

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_FrmPayPalLiteLegacyMigration::assertStringContainsString()


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

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 16, 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 (draft, code-level). One non-blocking note on test coverage; the sandbox-account validation you listed as remaining is still open and I did not exercise it.

What I ran at 56c8c91

  • Tests run: phpunit --filter test_FrmPayPalLiteLegacyMigration (wordpress-develop harness, PHP 8.4, PR tree swapped in) at 56c8c91 → OK, 7 tests / 23 assertions. CI skipped PHPUnit on this PR, so this run is the only one.
  • Real conversion through migrate() in a throwaway PHPUnit probe (not committed): a legacy subscription action with trial, paypal_stop_email, business email and return URL became a payment action with gateway paypal, type recurring, interval month, product name Gold, currency usd, amount 9.99, conditions kept. The legacy action went to draft, a second migrate() on it returned frm_paypal_migration_blocked (already has a payment action), and every email action with a create event moved to payment-success.
  • Live in the preview env (Lite at the PR head, Formidable PayPal add-on active, Pro from 2026-11-06): the notice renders inside the legacy action, the button is disabled with the amber blocker when After Payment rows exist and this Pro cannot run them, and enabled otherwise. Clicking Convert on an action without those rows showed the green success state with the four settings to review, focus landed on "Reload the page", and no console errors from the new code. After the reload the new payment action was there, the legacy one stayed draft in the DB, and saving the form with Update left it draft (the legacy action does not come back to life on save).

Blocked state (After Payment rows, Pro too old):

blocked

Success state:

success

Non-blocking

  • Coverage: the new tests cover convert_settings(), the blocker and the invalid-id path, but not migrate() end to end, move_emails_to_payment_success(), or migrate_action() (the AJAX handler's permission and nonce checks). Those are where a regression would do damage (the new action not being created, emails moved wrongly, an unauthenticated call). My probe above would make a good starting test.
  • test_after_payment_rows_need_a_supporting_pro_version starts with assertFalse( is_callable( 'FrmProTransLiteController::change_fields_after_payment' ) ), so it fails the day a Pro with that method is loaded in the same run. It is fine in Lite's own CI, but it is an environment-dependent assertion.

Not run: the "Pro supports After Payment" branch (the Pro in the env predates formidable-pro#6978, so the unblocked-with-rows path was only covered by the unit test), a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the review skills. DeepSource PHP is red; I did not open its findings.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 16, 2026
$blocker = $this->run_private_method( $method, array( $rows ) );

if ( $supported ) {
$this->assertSame( '', $blocker, 'A loaded After Payment integration should allow conversion.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

$this->assertSame( '', $blocker, 'A loaded After Payment integration should allow conversion.' );
return;
}
$this->assertStringContainsString( 'Activate Formidable Pro', $blocker, 'Without Pro, the conversion is blocked.' );

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_FrmPayPalLiteLegacyMigration::assertStringContainsString()


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

FrmFormAction::clear_cache();

$result = FrmPayPalLiteLegacyMigrationHelper::migrate( $legacy_id );
$this->assertIsArray( $result, 'A valid legacy action should convert.' );

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_FrmPayPalLiteLegacyMigration::assertIsArray()


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

$this->assertIsArray( $result, 'A valid legacy action should convert.' );
$payment = get_post( $result['action_id'] );
$settings = json_decode( $payment->post_content, true );
$this->assertSame( 'payment', $payment->post_excerpt, 'The new action should use Commerce.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

$payment = get_post( $result['action_id'] );
$settings = json_decode( $payment->post_content, true );
$this->assertSame( 'payment', $payment->post_excerpt, 'The new action should use Commerce.' );
$this->assertSame( array( 'paypal' ), $settings['gateway'], 'The converted action should use PayPal.' );

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_FrmPayPalLiteLegacyMigration::assertSame()


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

'action_id' => 0,
);
$_REQUEST['nonce'] = $nonce;
$this->_last_response = '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmPayPalLiteLegacyMigrationAjax::$_last_response


This issue is raised when an attempt is made to access an undefined property.
This may not have been intended, and it is advisable to give the code another look to make sure the property is defined in the scope it is used in.

);
$_REQUEST['nonce'] = $nonce;
$this->_last_response = '';
$this->assertSame( '-1', $this->trigger_action( 'frm_paypal_migrate_legacy_action' ), 'Invalid nonces should stop migration.' );

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_FrmPayPalLiteLegacyMigrationAjax::assertSame()


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

'action_id' => 0,
);
$_REQUEST['nonce'] = $_POST['nonce'];
$this->_last_response = '';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Access to an undefined property test_FrmPayPalLiteLegacyMigrationAjax::$_last_response


This issue is raised when an attempt is made to access an undefined property.
This may not have been intended, and it is advisable to give the code another look to make sure the property is defined in the scope it is used in.

$_REQUEST['nonce'] = $_POST['nonce'];
$this->_last_response = '';
$response = json_decode( $this->trigger_action( 'frm_paypal_migrate_legacy_action' ), true );
$this->assertFalse( $response['success'], 'An authorized request should report invalid action IDs.' );

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_FrmPayPalLiteLegacyMigrationAjax::assertFalse()


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

$this->_last_response = '';
$response = json_decode( $this->trigger_action( 'frm_paypal_migrate_legacy_action' ), true );
$this->assertFalse( $response['success'], 'An authorized request should report invalid action IDs.' );
$this->assertStringContainsString( 'legacy PayPal action could not be found', $response['data']['message'], 'A valid nonce should reach the migration helper.' );

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_FrmPayPalLiteLegacyMigrationAjax::assertStringContainsString()


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

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 16, 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 (draft, code-level) at 78d7572. The only change since my Approve at 56c8c91 is the new tests, which answer my coverage note. One small non-blocking note below.

  • Whole PR re-read at the new head. git diff 56c8c91 78d7572 touches two test files only; every source, view and JS file is byte-identical to what I reviewed at 56c8c91. The UI is unchanged, so the browser was not exercised at this head (see Not run).
  • migrate() now has a real end-to-end test: subscription settings land as payment / recurring / month / 9.99, the legacy action goes to draft, only the email with a create event moves (without duplicating payment-success), and a second migrate() returns frm_paypal_migration_blocked.
  • The AJAX handler now has its own test class: no permission and a subscriber stop before any lookup, a missing or wrong nonce returns -1, and a valid request reaches the helper.
  • The environment-dependent assertion I flagged is gone: the Pro test now branches on whether After Payment support is loaded.

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at 78d7572 (wordpress-develop harness, PHP 8.4, PR tree checked out in the plugin) -> OK, 10 tests / 41 assertions; --group ajax on the new class -> OK, 2 tests / 8 assertions. CI skipped PHPUnit on this PR, so these runs are the only ones.

I checked that the new tests fail when the code is broken, one change at a time:

  • Removing FrmAppHelper::permission_check( 'frm_edit_forms' ) from migrate_action() fails the capability test.
  • Removing check_ajax_referer() fails the nonce test.
  • Leaving create in the email events fails the migrate test.
  • Not saving the moved email action fails the migrate test.

php -l and php-cs-fixer (dry run, repo config) are clean on both test files.

Non-blocking

  • test_after_payment_rows_need_a_supporting_pro_version computes $supported with the same expression as the private after_payment_is_supported() in the helper. On a Pro that supports After Payment, the test then asserts '' from a copy of the logic it is checking. In this environment (no supporting Pro) it takes the blocker branch and passes for real. Calling the helper's own predicate through run_private_method would drop the duplicate expression.

DeepSource PHP is still red. I opened the findings this time. They are the apply_filters calls with extra arguments in migrate() (valid WordPress usage), undefined assert* methods on the test class (inherited from FrmUnitTest/PHPUnit) and view variables ($form_action, $blocker) defined by the including controller. They look like static-analysis false positives, but I did not trace each one to the include site.

Not run / not exercised: the browser at this head (the screenshots in my earlier review are for 56c8c91, same UI code), the "Pro supports After Payment" branch (the harness Pro predates formidable-pro#6978), a connected sandbox account, a real subscription, email triggers, PHPCS (the custom Formidable sniffs are not installed here), and the review skills (the delta is tests only).

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 16, 2026
The After Payment blocker test duplicated the expression from
after_payment_is_supported(). Call the private helper method instead so
the test cannot drift from the code it checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 17, 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 (draft, code-level) at 412d884. The only change since my Approve at 78d7572 is one line in a test, which answers my last non-blocking note.

  • Whole PR re-read at the new head. git diff 78d7572 412d884 touches tests/phpunit/paypal/test_FrmPayPalLiteLegacyMigration.php only (1 line). Every source, view, JS and CSS file is byte-identical to what I reviewed at 78d7572, and the PR's file list is unchanged.
  • test_after_payment_rows_need_a_supporting_pro_version now gets $supported from the helper's own private after_payment_is_supported() through run_private_method, instead of a copy of its expression. A change to the predicate can no longer leave the test checking a stale duplicate.

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at 412d884 (wordpress-develop harness, PHP 8.4, PR tree checked out in the plugin) → OK, 10 tests / 41 assertions. --group ajax on the migration classes → OK, 2 tests / 8 assertions. CI skipped PHPUnit on this PR, so these runs are the only ones.

I also forced the predicate both ways in a throwaway edit of the helper (reverted, harness restored): forced supported, the test takes its '' branch and passes (3 assertions); forced unsupported, it takes the blocker branch and passes (4 assertions). Both branches of the test now execute, including the one the harness Pro could not reach before. php -l is clean on the test file.

DeepSource PHP is still red. Same findings I opened last round (apply_filters extra args, inherited assert* methods, view variables from the including controller); nothing new in the one-line delta.

Not run / not exercised: UI not exercised at this head (no screenshot; the screenshots in my first review are for 56c8c91, and the UI code is unchanged), a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the review skills (the delta is one test line).

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 17, 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 (draft, code-level) at d74e5a5. The only change since my Approve at 412d884 is a merge of master (#3713, #3664, #3647, #3708, #3709 and others).

  • Whole PR re-read at this head. The PR's own diff against master is the same 9 files, 881 additions, 1 deletion, and every line of it is byte-identical to what I reviewed at 412d884 (git diff origin/master...412d884 and ...d74e5a5 are the same 955 lines). 0 behind master.
  • Nothing from the merged master PRs touches the PayPal legacy-migration files, hooks or views.

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at d74e5a5 (wordpress-develop harness, PHP 8.4, PR tree swapped in as the Lite plugin, restored after) → OK, 10 tests / 41 assertions. --group ajax on the migration classes → OK, 2 tests / 8 assertions. --filter FrmPayPalLite (all PayPal Lite tests, including master's FrmPayPalLiteActionsController additions from #3708) → OK, 27 tests / 76 assertions. CI skipped PHPUnit on this PR, so these runs are the only ones.

DeepSource PHP is still red. Same findings I opened on 2026-11-16 (apply_filters extra args, inherited assert* methods, view variables from the including controller); no new source in this delta.

Not run / not exercised: the browser at this head (UI code, views and CSS are byte-identical to 56c8c91, where I took the screenshots), a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the review skills (no code delta to review).

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 17, 2026
Crabcyborg and others added 2 commits November 18, 2026 15:50
Block the conversion while another published legacy PayPal action is on
the form. Converting one of two left the other sending entries to PayPal
Standard while the new action also charged, so an entry could be paid
twice.

Use the legacy add-on's currency fallback (its global setting, then USD)
for actions with no currency of their own, instead of the Formidable
default.

If the legacy action cannot be set to draft, delete the new action and
return an error. Keep email actions on Create when the payment action has
conditional logic, add the payment triggers to actions on the legacy
payment events, note that existing subscriptions stay on PayPal Standard,
and reload instead of saving the stale settings page after a conversion.

Register script translations for the PayPal admin script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 19, 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.

Request Changes (draft, code-level) at 2722975. One blocker: the new "other active legacy action" guard does not see actions saved with the paypal-legacy type, so the double-charge case this commit exists to stop is still reachable. The rest of the delta works.

Blocker (inline, with a suggestion): has_other_active_legacy_actions() asks FrmFormAction::get_action_for_form( $form_id, 'paypal', ... ) only, but $legacy_types in the same class is array( 'paypal', 'paypal-legacy' ) and is_legacy_action() treats both as legacy. An action added from the "PayPal (Legacy)" tile is saved as paypal-legacy.

  • Live, preview env at this head (PayPal add-on active, PayPal connected, form with two published paypal-legacy actions): both actions show an enabled "Convert to PayPal Commerce" button and no blocker. Converting the first one created the payment action (published) and turned the first legacy action into a draft; the second legacy action is still publish. That is a payment action next to a live legacy action, which is the state the commit message says it blocks.
  • With the suggested loop applied to the helper in the env, the same form shows "This form has other active legacy PayPal actions..." and the button is disabled. (Env edit reverted afterwards.)
  • The same hole applies to one paypal action plus one paypal-legacy action on a form.

Blocker shown for two legacy paypal actions

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at 2722975 (wordpress-develop harness, PHP 8.4, PR tree swapped in as the Lite plugin, restored after) -> OK, 13 tests / 52 assertions. CI skipped PHPUnit, so this is the only run. I broke the code one change at a time: removing the other-legacy-action check, the conditional-logic hold on the email move, the added payment triggers, and the legacy-currency fallback each fail a test. Replacing the wp_update_post failure branch with if ( false ) fails nothing (see below).

Also checked live (the screenshot above is the blocked state for two paypal actions): with one legacy action, Convert gives the new notes (legacy subscriptions stay on PayPal Standard; 1 email moved to Successful Payment; 1 action that ran after a legacy payment now also runs after a Commerce payment). After the conversion the payment action has usd, 9.99, recurring; the email that was on create now has payment-success; the action that was on the legacy paypal event now has paypal and payment-success. Clicking Update on the converted page reloaded it, and afterwards the payment action was still published and the legacy one still draft.

Non-blocking

  • The rollback in migrate() (new payment action deleted when the legacy action cannot be set to draft) has no test; the branch can be removed without a failure. A test that makes wp_update_post fail (a wp_insert_post_empty_content-style filter or a stubbed post id) would cover it.
  • $form_id = $legacy_action->menu_order; lost its (int) cast in this commit, so get_migration_blocker() now receives a string there. It works, but get_action_for_form() and the other callers are written for an int.

Not run: the "reload instead of saving" handler without the PR's JS (I did not compare with the previous head, only that the page reloads and the saved state is right), a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the code-review/security-review/simplify skills (I read the whole 297-line delta instead; the rest of the PR is unchanged from my earlier Approves).

Comment on lines +85 to +89
$legacy_actions = FrmFormAction::get_action_for_form( $form_id, 'paypal', array( 'post_status' => 'publish' ) );

if ( ! is_array( $legacy_actions ) ) {
return false;
}

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.

$legacy_types (line 21) and is_legacy_action() count both paypal and paypal-legacy as legacy, but this query only loads the paypal type. A form with two published paypal-legacy actions (the "PayPal (Legacy)" tile) gets no blocker, so converting one leaves the other publishing next to the new payment action. I reproduced that in the preview env at this head. Query every legacy type:

Suggested change
$legacy_actions = FrmFormAction::get_action_for_form( $form_id, 'paypal', array( 'post_status' => 'publish' ) );
if ( ! is_array( $legacy_actions ) ) {
return false;
}
$legacy_actions = array();
foreach ( self::$legacy_types as $legacy_type ) {
$found = FrmFormAction::get_action_for_form( $form_id, $legacy_type, array( 'post_status' => 'publish' ) );
if ( is_array( $found ) ) {
$legacy_actions += $found;
}
}

With this in place the same two-action form shows the blocker and a disabled Convert button. get_action_for_form() returns array() for a type that is not registered, so the loop is safe when the legacy add-on is inactive. A test with one paypal and one paypal-legacy action would keep it from regressing (the existing test only uses paypal).

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 19, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 23, 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 (draft, code-level) at 74b0d22. The blocker from my Request Changes at 2722975 is fixed, and both non-blocking notes from that review are answered.

  • Blocker fixed. has_other_active_legacy_actions() now queries the stored actions with both $legacy_types (paypal and paypal-legacy) through a prepared %i query. %i needs WP 6.3+, which is the plugin's minimum. It matches on post_status = publish, so a draft legacy action still does not block, and it excludes the action being converted.
  • Live, preview env at this head (Lite on the PR branch, helper called through a throwaway mu-plugin, removed afterwards): two published paypal-legacy actions on one form now return the "other active legacy PayPal actions" blocker. A paypal plus a paypal-legacy action on one form is blocked too, and a form with one legacy action has no blocker. The same two-paypal-legacy form at 2722975 returned no blocker, so the bug is reproduced before and gone after.
  • Rollback test added. test_migrate_rolls_back_when_legacy_action_cannot_be_disabled forces wp_update_post to fail and asserts the frm_paypal_migration_failed error, the legacy action still publish, and no payment action left behind. The (int) cast on $form_id is back.
  • Whole PR re-read at this head. Since my review at 2722975 the commit touches only the helper and the migration test, and the rest of the PR is unchanged. None of the PR's 10 files were touched on master since the merge base (9 ahead, 7 behind).

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at 74b0d22 (wordpress-develop harness, PHP 8.4, PR tree swapped in as the Lite plugin, restored after) → OK, 14 tests / 56 assertions. --group ajax on the migration classes → OK, 2 tests / 8 assertions. --filter FrmPayPalLite → OK, 36 tests / 109 assertions. CI skipped PHPUnit on this draft, so these runs are the only ones.

I broke the code one change at a time, and each change fails a test:

  • Dropping paypal-legacy from the query fails test_migrate_is_blocked_while_another_legacy_action_is_active.
  • Removing the wp_delete_post( $new_action_id, true ) rollback fails the new rollback test.

DeepSource PHP and JS, DeepScan, Psalm, Scrutinizer and Typos are green. php -l is clean on the helper.

Not run / not exercised: the browser UI at this head (no view, CSS or JS change since my earlier live runs), a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the review skills (I read the whole delta by hand).

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 23, 2026
The legacy PayPal migration notice heading said "Upgrade to PayPal
Commerce" while the button below it says "Convert to PayPal Commerce".
Use the same wording in both places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Crabcyborg Crabcyborg modified the milestones: 7.2, 7.3 Nov 26, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 27, 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 (draft, code-level) at 20900f2. The only change to the PR's own code since my Approve at 74b0d22 is one string, plus two merges of master.

  • Whole PR re-read at this head. The PR's diff against master (git diff origin/master...20900f2) and the same diff at 74b0d22 differ by one line: the heading in paypal/views/settings/legacy-migration-notice.php changed from "Upgrade to PayPal Commerce" to "Convert to PayPal Commerce" (cb4c203). Every other line of the 10-file diff is byte-identical. The heading now matches the button and the docblock in the controller; no other "Upgrade to PayPal" string is left in paypal/.
  • Live, preview env with Lite at 20900f2 (PayPal add-on active, PayPal connected, a form with one legacy paypal subscription action): the notice shows the new heading with a matching enabled button, and Convert gave the green success state with the four settings to review. Afterwards the payment action was published and the legacy one was draft.

Notice at this head (the onboarding checklist on the right is the env's, not the PR's):

notice

After Convert:

success

Tests run: phpunit -c phpunit9.xml --filter test_FrmPayPalLiteLegacyMigration at 20900f2 (wordpress-develop harness, PHP 8.2, PR tree swapped in as the Lite plugin, restored after) → OK, 14 tests / 56 assertions. --group ajax --filter LegacyMigration → OK, 2 tests / 8 assertions. --filter FrmPayPalLite → OK, 36 tests / 109 assertions. CI skipped PHPUnit on this draft, so these runs are the only ones.

Not run / not exercised: a connected sandbox account, a real subscription, email triggers, PHPCS/PHPStan, and the review skills (the PR's own delta is one string; I read it by hand). Nothing in the merged master PRs touches the PayPal legacy-migration files.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 27, 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