[Paragraphs] PHP 8.1 TypeError: Drupal\webform\WebformRequest::getUrl()

Created on 25 September 2022, almost 2 years ago
Updated 8 April 2024, 3 months ago

Problem/Motivation

TypeError: Drupal\webform\WebformRequest::getUrl(): Argument #1 ($webform_entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in web/modules/contrib/webform/src/WebformMessageManager.php on line 247 in Drupal\webform\WebformRequest->getUrl() (line 229 of web/modules/contrib/webform/src/WebformRequest.php) #0 web/modules/contrib/webform/src/WebformMessageManager.php(247): Drupal\webform\WebformRequest->getUrl()

Proposed resolution

Check that webform_entity isn't null before using getUrl().

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡©πŸ‡°Denmark pmchristensen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom siliconandincense

    I know this has been set as closed, but I am also getting this error by using the following steps:

    1) I have a regular content type page that is already published
    2) I set this page as draft and save it
    3) I add a webform via a paragragraph, which has a webform reference field on it
    4) I save the page
    5) I view the page and get the same error as above

    I know this is a very personalised set of steps, but I'm hoping this may shed a little more light on the issue.

    Can confirm #2 works, but as you say in #3 we get the submission message.

    Apologese if this has been sorted in a subsequent ticket.

  • πŸ‡·πŸ‡΄Romania mihai_brb

    I got this error when the Webform reference field is attached to a Paragraph - that is attached to a Node.
    Patch works.

  • Status changed to Active about 1 year ago
  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    The patch is most likely suppressing a larger issue with how the last submission is being determined.

    We need to come up with simpler steps to reproduce the issue.

  • Status changed to Closed: duplicate about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • Status changed to Active about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    I think #5 is catching that the issue has something to do with a webform embed via paragraph is not determining the correct source entity.

    Paragraphs have become an ongoing challenge, and adjusting any of the existing logic without causing regressions is tough.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • πŸ‡ΊπŸ‡ΈUnited States gcb

    I have the same issue, manifesting when I load up the layout builder configuration for a view mode for the entity.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    The proposed fix causes the switch/case to fall through to the next switch.

          case WebformMessageManagerInterface::PREVIOUS_SUBMISSION:
             $webform_submission = $this->getSubmissionStorage()->getLastSubmission($webform, $source_entity, $this->currentUser);
    -        $args = [':href' => $this->requestHandler->getUrl($webform_submission, $source_entity, 'webform.user.submission')->toString()];
    -        return $this->getCustomMessage('previous_submission_message', $args);
    +        if ($webform_submission) {
    +          $args = [':href' => $this->requestHandler->getUrl($webform_submission, $source_entity, 'webform.user.submission')->toString()];
    +          return $this->getCustomMessage('previous_submission_message', $args);
    +        }
     
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
Production build 0.69.0 2024