Problem/Motivation

WebformNavigationHelper::logPageErrors() (src/WebformNavigationHelper.php:288-317) runs on every validate of a navigation-enabled webform, including every Next, Previous, progress-link click and draft save. Each run:

  1. SELECTs the latest errors row (getErrors()).
  2. DELETEs all non-visit rows for the submission (:294 → deleteSubmissionLogs($webform_submission, TRUE)).
  3. For each form error, calls logPageVisit($webform_submission, $current_page) (:304). The argument is the same $current_page on every iteration, so this is one identical hasVisitedPage() SELECT per error. It looks like either $page was intended, or the call belongs outside the loop.
  4. INSERTs a new serialized errors row (:316).

A page with many errors (for example a required composite with many rows) therefore runs 3 + N queries per validate, and each step deletes and re-inserts the error row.

Separately, WebformNavigationHandler::alterForm() calls hasVisitedPage() (:143) and then logPageVisit() (:146), which calls hasVisitedPage() again (:240). That is two identical SELECTs.

Proposed resolution

  • Move the logPageVisit() call out of the per-error loop and call it once. Also confirm whether $page or $current_page is the intended argument.
  • Store at most one errors row per submission and write it with merge() keyed on (webform_id, sid, operation) instead of DELETE + INSERT. Skip the write when the serialized errors haven't changed.
  • In alterForm(), call logPageVisit() directly, since it already checks hasVisitedPage().

Remaining tasks

  • Write the MR.
  • Add a test that error logging and the progress-bar error/complete classes behave as before.
  • Decide whether to add an update hook that collapses existing duplicate errors rows into one, or simply let the next write replace them.

User interface changes

None.

API changes

None.

Data model changes

There will be at most one errors row per submission. A unique key on (webform_id, sid, operation) can't be added, because the page visited rows legitimately repeat that key. The merge can key on lid found by a lookup, or the module can use a separate errors table.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rymcveigh created an issue. See original summary.

shubhamgoel made their first commit to this issue’s fork.

shubhamgoel’s picture

Status: Active » Needs review

Hi Team,

The issue has been fixed. Please review and merge the MR https://git.drupalcode.org/project/webformnavigation/-/merge_requests/30....

rymcveigh’s picture

I would like to address this issue before this work to ensure our changes don't introduce regressions. It would be great if you could help review it so that we can progress with this issue.

rymcveigh’s picture

Version: 2.0.x-dev » 2.1.x-dev
rymcveigh’s picture

Status: Needs review » Needs work
shubhamgoel’s picture

Status: Needs work » Needs review

Hi @rymcveigh,

I have rebased the MR and also applied all the feedbacks. Please review and merge the MR.

rymcveigh’s picture

Status: Needs review » Reviewed & tested by the community

rymcveigh’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.