Skip to content

Fix fatal error when importing forms with no valid form ID in rate limiting check#597

Merged
iruzevic merged 2 commits intomainfrom
copilot/fix-import-forms-error
Mar 11, 2026
Merged

Fix fatal error when importing forms with no valid form ID in rate limiting check#597
iruzevic merged 2 commits intomainfrom
copilot/fix-import-forms-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

During form import in a multisite environment, the fileUploadAdmin route is invoked with formId='0'. PHP's falsy evaluation of '0' caused RateLimitingLogEntry::write() to throw a RuntimeException before the entry could be written.

Change

Added an early bailout in Security::isRequestValid() for non-positive-integer form IDs — admin/import operations have no real form context and should not be subject to rate limiting:

// Bailout if the form ID is not a valid form ID. Admin operations may not have a form ID.
if (!\is_numeric($formId) || (int)$formId <= 0) {
    return true;
}

Uses is_numeric() + explicit <= 0 check rather than a raw cast to avoid silently passing non-numeric strings (e.g. '0abc').

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] - Error when attempting to import forms</issue_title>
<issue_description>I got a fatal error when trying to import form from one site to another site in a multisite environment:

PHP Fatal error:  Uncaught RuntimeException: Form ID is required to write a rate limiting log entry. in /plugins/eightshift-forms/src/Security/RateLimitingLogEntry.php:57
Stack trace:
infinum/eightshift-forms#0 /plugins/eightshift-forms/src/Security/Security.php(78): EightshiftForms\\Security\\RateLimitingLogEntry->write()
infinum/eightshift-forms#1 /plugins/eightshift-forms/src/Rest/Routes/AbstractIntegrationFormSubmit.php(195): EightshiftForms\\Security\\Security->isRequestValid('fileUploadAdmin', '0')
infinum/eightshift-forms#2 /home/infobip/releases/current/wp-includes/rest-api/class-wp-rest-server.php(1292): EightshiftForms\\Rest\\Routes\\AbstractIntegrationFormSubmit->routeCallback(Object(WP_REST_Request))
infinum/eightshift-forms#3 /home/infobip/releases/current/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/eightshift-for...', Array, NULL)
infinum/eightshift-forms#4 /home/infobip/releases/current/wp-includes/rest-api/class-wp-rest-server.php(439): WP_REST_Server->dispatch(Object(WP_REST_Request))
infinum/eightshift-forms#5 /home/infobip/releases/current/wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/eightshift-for...')
infinum/eightshift-forms#6 /home/infobip/releases/current/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
infinum/eightshift-forms#7 /home/infobip/releases/current/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
infinum/eightshift-forms#8 /home/infobip/releases/current/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
infinum/eightshift-forms#9 /home/infobip/releases/current/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
infinum/eightshift-forms#10 /home/infobip/releases/current/wp-includes/class-wp.php(818): WP->parse_request('')
infinum/eightshift-forms#11 /home/infobip/releases/current/wp-includes/functions.php(1342): WP->main('')
infinum/eightshift-forms#12 /home/infobip/releases/current/wp-blog-header.php(16): wp()
infinum/eightshift-forms#13 /home/infobip/releases/current/index.php(17): require('/home/infobip/r...')
infinum/eightshift-forms#14 {main}
  thrown in /plugins/eightshift-forms/src/Security/RateLimitingLogEntry.php on line 57"

We have rate limit log db tables in every multisite, same plugin. Not sure what seems to be the issue here.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…positive integer

Co-authored-by: goranalkovic-infinum <77000136+goranalkovic-infinum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fatal error when importing forms in multisite Fix fatal error when importing forms with no valid form ID in rate limiting check Mar 10, 2026
@goranalkovic-infinum goranalkovic-infinum requested a review from a team March 10, 2026 13:30
@goranalkovic-infinum goranalkovic-infinum marked this pull request as ready for review March 10, 2026 13:39
@iruzevic iruzevic merged commit 8e56bf1 into main Mar 11, 2026
3 checks passed
@iruzevic iruzevic deleted the copilot/fix-import-forms-error branch March 11, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - Error when attempting to import forms

3 participants