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
{{ message }}
Repository navigation
Commit ff0d80c
Browse filesBrowse the repository at this point in the historyBrowse files
fix: never drop a settings error when its field can't be found
Credential errors had no fallback: if Gravity Forms couldn't find the
named field, the error was lost and a refused key would save. While
validate_credentials() runs, errors now fall back to the Mode field, and
an error with nowhere to go is logged. Scope labels in key errors are
escaped, since Gravity Forms prints field errors as HTML.
Tests: the stub set_field_error() now throws on anything Gravity Forms
would ignore, the fixture renderer only finds the add-on's defined
fields, and the fallback paths are covered.
Note on f37a492: the array argument crashed on every supported PHP
version (7.2+), not only PHP 8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
$this->set_setting_error('api_mode', sprintf(esc_html__('Your %1$s settings have a problem. Select %2$s to see it. No settings were saved.', 'gravityformspaystack'), $mode, $mode === 'test' ? esc_html__('Test', 'gravityformspaystack') : esc_html__('Live', 'gravityformspaystack')));
2128
+
$this->set_setting_error('api_mode', sprintf(esc_html__('Your %1$s settings have a problem. Select %2$s to see it. No settings were saved.', 'gravityformspaystack'), $mode, $mode === 'test' ? esc_html__('Test', 'gravityformspaystack') : esc_html__('Live', 'gravityformspaystack')), $field);
gf_paystack_test_check(!preg_match('/set_field_error\(\s*array\(/', $plugin_src), 'no field error is raised with an array (Gravity Forms 2.5+ needs the field object)');
437
+
gf_paystack_test_check(substr_count($plugin_src, '->set_field_error(') === 1, 'set_field_error is only called from set_setting_error');
gf_paystack_test_check(!array_diff($wanted, $names), 'every field an error is raised on is a defined settings field: missing ' . implode(',', array_diff($wanted, $names)));
441
+
// metaData is added after Gravity Forms' own billingInformation field, which the stubs don't build.
442
+
gf_paystack_test_check(preg_match("/'name'\\s*=>\\s*'metaData'/", $plugin_src) === 1, 'metaData is a defined feed field');
443
+
444
+
// If a field can't be found, the credential error lands on the Mode field instead of being dropped.
445
+
$cred_lookup_fails = function ($posted, $stored = array()) {
gf_paystack_test_check(strpos($a->field_errors['api_mode'] ?? '', 'Use a test restricted key instead.') === 0, 'credentials: selected-mode key error falls back to Mode when its field is missing');
gf_paystack_test_check($a->field_errors === array() && strpos(json_encode($GLOBALS['gf_paystack_test_gf_logs']), 'no settings field to attach an error to (nope)') !== false, 'an error with nowhere to go is logged, not silently dropped');
0 commit comments