Problem/Motivation

When wizard_progress_states is enabled, Webform::getPages($operation, $webform_submission) re-evaluates every page's #states through webform_submission.conditions_validator on every call. Webform doesn't cache that result.

The module calls it more often than it needs to:

  • getCurrentPage() (src/WebformNavigationHelper.php:144-147) calls getPages() even when $webform_submission->getCurrentPage() is already set. The result is only used as a fallback.
  • hasAccessToPage() (:490-494) calls getPages() on every call, including inside the validateAllPages() loop (:408) and the error loop in WebformNavigationHandler::validateForm().
  • alterForm() and both progress preprocess hooks each call it again.

Proposed resolution

  • In getCurrentPage(), return the submission's current page directly when it is set, and only call getPages() as the fallback.
  • In hasAccessToPage(), and in loops that call it, compute the accessible page keys once per submission per request and reuse them. This could share the memo proposed in the "memoize getErrors()/hasVisitedPage()" issue.

Remaining tasks

  • Write the MR.
  • Check that the cached page list is refreshed when values change during the same request, since conditional pages depend on submission data.

User interface changes

None.

API changes

None.

Data model changes

None.

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,

getCurrentPage(): It now returns the submission's current page directly when it is set. It only looks up the pages when none is set, and then returns the first one.
hasAccessToPage(): It now reads the accessible page keys from a new getAccessiblePageKeys() helper.

Please review and merge the MR https://git.drupalcode.org/project/webformnavigation/-/merge_requests/29....

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 review it so we can move forward 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 to reflect the latest changes. Please review and merge the MR