Because of [issue 324: Signature of DevelGenerateBaseInterface::validateDrushParams() different in 8.x-2.1 and 4.0.0, causing fatal Declaration of ... must be compatible error., if you use webform 8.x-5.x-dev with Devel's devel_generate module version 4.0.0, you get:

Fatal error: Declaration of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::validateDrushParams($args) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams(array $args, array $options = Array).

when submitting a form which has an email handler.

This is mitigated by the fact that it is not a good idea to enable devel_generate on production, so this probably won't happen in production, but on dev/stage servers with devel_generate enabled, it will cause fatal errors.

I cannot think of a workaround; perhaps it is best to remove Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate entirely until devel issue 324 is fixed?

Setting to major because this might cause webforms to not work on critical environments if devel_generate is enabled.

Issue fork webform-3155654

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

alberto56 created an issue. See original summary.

alberto56’s picture

According to @weitzman:

Packages are welcome to use the conflict metadata built into Composer, among other mechanisms.

So it seems it is up to Webform to make sure it does not use an incompatible base plugin.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new36.17 KB

The attached patch supports both Devel <4.0 and >4.0 by altering the webform submission devel generate class.

I don't love supporting hacks like this but the WebformSubmissionDevelGenerate is rarely updated.

alberto56’s picture

Status: Needs review » Needs work

Thanks! I like the idea, (although in a perfect world I don't think it should be up to module maintainers to do this, as I've documented in #3155737: If a Throwable occurs when a Plugin is loaded, log an error and move on, do not die with a fatal error). One potential issue is that this patch assumes there is a "version" string in /var/www/html/modules/contrib/devel/devel_generate/devel_generate.info.yml, but $info['version'] will be NULL for users who have the development snapshot of devel-8.x-2.x. Probably an edge case, but I thought it worth mentioning!

I will set to "needs work" the following scenario still fails.

Step 1:

Install Webform 5.18 and Devel 8.x-2.1

Step 2:

Apply the patch from #3 to Webform

Step 3:

drush en webform_example_custom_form webform_ui devel devel_generate -y

Step 4:

/admin/structure/webform/manage/webform_example_custom_form/handlers

Step 5:

Press "+ add email" and in the "Add Email handler" section, press "Save"

Step 6:

Go to /webform/webform_example_custom_form/test

Step 7:

Press "Submit". For me, I am expecting it to work, but I get:

Fatal error: Declaration of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::validateDrushParams(array $args, array $options = Array) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams($args) in /var/www/html/modules/contrib/webform/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php on line 32

I can confirm webform_devel_generate_info_alter() is being called and "strpos($info['version'], '8.x-') === 0" returns TRUE, so something else seems to be triggering this problem.

For what it's worth, steps 4 and 5, above, are necessary to reproduce the problem; if you don't add an email handler everything works fine.

alberto56’s picture

Issue summary: View changes
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new36.2 KB

I think you just need to clear the cache before opening the UI. Drush does not use the same cache as the website which would explain why it worked via Drush and not the UI.

The attached patch accounts for no $info['version'], my assumption is that when the $info['version'] is missing the developer is NOT using an older version of the devel.module.

alberto56’s picture

Status: Needs review » Needs work

Thanks. I'm still getting the error so I reinstalled everything from scratch, including Drupal and Drush, on a completely new Docker container, and I still cannot get this patch to work with devel 2.1.

Seems to be related to the autoloading mechanism and webform sending an email.

Here are complete steps starting from a blank machine:

* Install drush 10.3.0
* Install Drupal 8.9.1
* Install a fresh Drupal:

drush si -y

* Download webform and devel

export COMPOSER_MEMORY_LIMIT=-1 && composer require drupal/webform drupal/devel:~2.1

* Make sure we have the 2.1 version of devel and the latest version of webform:

$ drush pml|grep \(webform\)
  Webform         Webform (webform)                   Disabled   8.x-5.18       
$ drush pml|grep \(devel_generate\)
  Development     Devel Generate (devel_generate)     Disabled   8.x-2.1        

* Enable some modules:

drush en webform_example_custom_form webform_ui devel devel_generate -y

* Apply the patch

cd /var/www/html/modules/contrib/webform
curl -O https://www.drupal.org/files/issues/2020-06-30/3155654-6.patch
patch -p1 < 3155654-6.patch
rm 3155654-6.patch

* Clear all caches for good measure:

drush cr
drush cc drush

* Log in as user 1 and go to /admin/structure/webform/manage/webform_example_custom_form/handlers

* Press "+ add email" and in the "Add Email handler" section, press "Save"

* Go to /webform/webform_example_custom_form/test

* Press "Submit". For me, I am expecting it to work, but I still get the error.

Fatal error: Declaration of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::validateDrushParams(array $args, array $options = Array) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams($args) in /var/www/html/modules/contrib/webform/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php on line 32

I added the following code before the class declaration (just after the "use" declarations) at /var/www/html/modules/contrib/webform/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php:

die(print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));

Here is a partial trace which leads to WebformSubmissionDevelGenerate being autoloaded instead of WebformSubmissionDevelGenerateDeprecated:

Array
(
    [0] => Array
        (
            [file] => /var/www/html/vendor/composer/ClassLoader.php
            [line] => 444
            [function] => include
        )

    [1] => Array
        (
            [file] => /var/www/html/vendor/composer/ClassLoader.php
            [line] => 322
            [function] => Composer\Autoload\includeFile
        )

    [2] => Array
        (
            [function] => loadClass
            [class] => Composer\Autoload\ClassLoader
            [type] => ->
        )

    [3] => Array
        (
            [file] => /var/www/html/modules/contrib/webform/webform.module
            [line] => 392
            [function] => spl_autoload_call
        )

    [4] => Array
        (
            [file] => /var/www/html/core/lib/Drupal/Core/Mail/MailManager.php
            [line] => 271
            [function] => webform_mail
        )

    [5] => Array
        (
            [file] => /var/www/html/core/lib/Drupal/Core/Mail/MailManager.php
            [line] => 179
            [function] => doMail
            [class] => Drupal\Core\Mail\MailManager
            [type] => ->
        )

    [6] => Array
        (
            [file] => /var/www/html/core/lib/Drupal/Core/Render/Renderer.php
            [line] => 573
            [function] => Drupal\Core\Mail\{closure}
            [class] => Drupal\Core\Mail\MailManager
            [type] => ->
        )

    [7] => Array
        (
            [file] => /var/www/html/core/lib/Drupal/Core/Mail/MailManager.php
            [line] => 180
            [function] => executeInRenderContext
            [class] => Drupal\Core\Render\Renderer
            [type] => ->
        )

    [8] => Array
        (
            [file] => /var/www/html/modules/contrib/webform/src/Plugin/WebformHandler/EmailWebformHandler.php
            [line] => 1202
            [function] => mail
            [class] => Drupal\Core\Mail\MailManager
            [type] => ->
        )

I cannot make sense of why we are loading this as it is useless to send emails, but that seems to be how it's done.

jrockowitz’s picture

I can't replicate your issue. I only see the error before I clear the cache. You would need to debug webform_devel_generate_info_alter() and see if it is being executed as expected.

alberto56’s picture

Thanks @jrockowitz

So our situation now is we both have:

* New standard install of Drupal 8.9.1
* Drush 10.3.0
* Webform 8.x-5.18 with the patch at #6
* Devel 8.x-2.1 (not 4.0.0)'s devel_generate enabled
* A webform with an Email handler

In your case after clearing drush and drupal cache (drush cr; drush cc drush) you can submit the webform with the email handler and you do not get a fatal error.

In my case after clearing drush and drupal cache (drush cr; drush cc drush) I systematically get the fatal error.

The only thing which might differ between our environments, then, is the PHP version and composer file. Anything else?

My php version is

PHP 7.4.7 (cli) (built: Jun 11 2020 18:33:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.7, Copyright (c), by Zend Technologies

And my composer file is:

{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 8 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "drupal/bootstrap": "^3.23",
        "drupal/core-composer-scaffold": "^8.8",
        "drupal/core-project-message": "^8.8",
        "drupal/core-recommended": "^8.8",
        "drupal/core-vendor-hardening": "^8.8",
        "drupal/devel": "~2.1",
        "drupal/field_group": "^3.1",
        "drupal/masquerade": "^2.0@beta",
        "drupal/metatag": "^1.13",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/smtp": "^1.0@RC",
        "drupal/stage_file_proxy": "^1.0",
        "drupal/token": "^1.7",
        "drupal/webform": "^5.18",
        "drush/drush": "~10"
    },
    "require-dev": {
        "drupal/core-dev": "^8.8"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "./"
            }
        },
        "installer-paths": {
            "./core": ["type:drupal-core"],
            "./libraries/{$name}": ["type:drupal-library"],
            "./modules/contrib/{$name}": ["type:drupal-module"],
            "./profiles/contrib/{$name}": ["type:drupal-profile"],
            "./themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"],
            "./modules/custom/{$name}": ["type:drupal-custom-module"],
            "./themes/custom/{$name}": ["type:drupal-custom-theme"]
        },
        "drupal-core-project-message": {
            "include-keys": ["homepage", "support"],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",

                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}

It would be cool to get to the bottom of why I can reproduce this on a new test environment and it also happens on a production environment, but in your case it does not happen...

I will leave this at "needs review" as I cannot confirm it works for me; but I cannot provide a reproducible error either.

alberto56’s picture

Status: Needs work » Needs review
alberto56’s picture

@jrockowitz

Another question: with the following setup:

* New standard install of Drupal 8.9.1
* Drush 10.3.0
* Webform 8.x-5.18 unpatched enabled
* Devel 4.0.0 (not 8.x-2.1)'s devel_generate enabled
* A webform with an Email handler
* drush cc drush && drush cr

When you submit a webform with the email handler, can you reproduce a fatal error? If not we should bring the priority of this to normal.

jrockowitz’s picture

PHP 7.4 might be the source of the problem.

BTW, I am testing the default Contact webform.

alberto56’s picture

Status: Needs review » Needs work
StatusFileSize
new112.62 KB

Happens with PHP 7.3 also, on an Acquia environment.

I think I found the issue:

In webform.module at line 392, there is the following code:

/**
 * Implements hook_mail().
 */
function webform_mail($key, &$message, $params) {
  // Never send emails when using devel generate to create 1000's of
  // submissions.
  if (\Drupal::moduleHandler()->moduleExists('devel_generate')
    && \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::isGeneratingSubmissions()) {
    $message['send'] = FALSE;
  }

Here we will need to use the correct class also (WebformSubmissionDevelGenerate for devel >= 4.0.0, otherwise WebformSubmissionDevelGenerateDeprecated.

I can't figure out why you cannot reproduce the issue, though. Are you sure devel_generate is enabled on your environment, and you are using an email handler when submitting the form?

alberto56’s picture

I also did a quick search for WebformSubmissionDevelGenerate in the Webform codebase and found:

$ grep -R 'WebformSubmissionDevelGenerate' .
./webform.module:    && \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::isGeneratingSubmissions()) {
Binary file ./.git/index matches
./modules/webform_demo/webform_demo_application_evaluation/webform_demo_application_evaluation.install:      /** @var \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate $webform_submission_devel_generate */
./modules/webform_demo/webform_demo_application_evaluation/webform_demo_application_evaluation.install:    /** @var \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate $webform_submission_devel_generate */
./src/WebformSubmissionGenerate.php: * @see \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate
./src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php: * Provides a WebformSubmissionDevelGenerate plugin.
./src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php:class WebformSubmissionDevelGenerate extends DevelGenerateBase implements ContainerFactoryPluginInterface {
./src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php:   * Constructs a WebformSubmissionDevelGenerate object.
./src/WebformSubmissionGenerateInterface.php: * @see \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate
./src/Commands/WebformCliService.php:    /** @var \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate $instance */

So this might need to be fixed elsewhere also.

dom.’s picture

I just wanted to add that I ran into the issue with a client site in production using PHP 7.2.24-0ubuntu0.18.04.6, Webform 8.x-5.16 and Devel 4.0.0-rc1.

jrockowitz’s picture

StatusFileSize
new0 bytes

I think the attached patch solves the problem.

jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

Priority: Major » Critical

I am bumping this to critical because it will require an immediate release once the issue is resolved.

alberto56’s picture

Status: Needs review » Needs work

@jrockowitz thanks. The patch says 0 bytes and loads as a blank page for me.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new38.07 KB
alberto56’s picture

Status: Needs review » Needs work

This portion of the patch is causing issues for me, is it there by mistake:

diff --git a/src/WebformHelpManager.php b/src/WebformHelpManager.php
index 5802ffe9e..6c9e3157c 100644
--- a/src/WebformHelpManager.php
+++ b/src/WebformHelpManager.php
@@ -1364,12 +1364,6 @@ class WebformHelpManager implements WebformHelpManagerInterface {
         'youtube_id' => 'WQG6163r9Rs',
         'presentation_id' => '1Mn7qlSR_njTZcGAM3PNQZR8Tvg7qtPhZFQja7Mj5uzI',
       ],
-      'everyone' => [
-        'title' => $this->t('Webforms for Everyone'),
-        'content' => $this->t('This presentation explores how site owners, site builders, and developers can leverage the Webform module for Drupal 8 to build complex and robust forms for their end-users.'),
-        'youtube_id' => 'zvilAbrczGM',
-        'presentation_id' => '1APpt-55Ht_WLZc656KfQUXUoIAb-PTOmbMwSYSAw6G4',
-      ],
     ];
 

I'll set to needs work.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new37.24 KB

Sorry about that.

alberto56’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the great work and fast response!

I'll set this to RTBC based on the following tests:

* Patched webform 5.18 and Devel 8.x-2.1, submitting a form with an email handler works.
* Patched webform 5.18 and Devel 4.0.0, submitting a form with an email handler works.

(I ran into #3156132: Warning: htmlspecialchars() expects parameter 1 to be string while testing thing but I think it's unrelated so I opened a new issue.)

This patch will also make it to the 6.x branch through the regular process, correct?

  • jrockowitz authored 2873a49 on 8.x-5.x
    Issue #3155654 by jrockowitz, alberto56: Declaration of Drupal\webform\...

  • jrockowitz authored 2873a49 on 6.x
    Issue #3155654 by jrockowitz, alberto56: Declaration of Drupal\webform\...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed
jrockowitz’s picture

I committed the patch. I will tag a release in the next day or so.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

awolfey’s picture

Priority: Critical » Normal
StatusFileSize
new612 bytes

I found one more incompatibility. Patch attached.

Posting here instead of a new issue for ease of use / search.

jrockowitz’s picture

Status: Closed (fixed) » Reviewed & tested by the community

  • awolfey authored 9d47d05 on 8.x-5.x
    Issue #3155654 by jrockowitz, awolfey, alberto56: Declaration of Drupal\...

  • awolfey authored 9d47d05 on 6.x
    Issue #3155654 by jrockowitz, awolfey, alberto56: Declaration of Drupal\...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

stijnhau’s picture

Still had this issue in 6.0.2.
Had to alter patch #29 to get it working

diff --git a/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php b/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
index 1eb2c5b6c..fe42a0151 100644
--- a/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
+++ b/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
@@ -32,8 +32,8 @@ class WebformSubmissionDevelGenerate extends DevelGenerateBase implements Contai
   /**
    * {@inheritdoc}
    */
-  public function validateDrushParams($args) {
-    return $this->_validateDrushParams($args);
+  public function validateDrushParams(array $args, array $options = []) {
+    return $this->_validateDrushParams($args, $options);
   }

 }
artis’s picture

StatusFileSize
new668 bytes

rerolled #36 text patch as a file for ease of adding to composer.json

jrockowitz’s picture

Status: Closed (fixed) » Needs work
jrockowitz’s picture

jrockowitz’s picture

Version: 8.x-5.x-dev » 6.x-dev
jrockowitz’s picture

Title: Declaration of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::validateDrushParams($args) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams(array $args, array $options = Array) » [Drupal 9.x] Declaration of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::validateDrushParams($args) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams(array $args, array $options = Array)
Status: Needs work » Postponed
Parent issue: » #3249740: [META] Ensure webform compatibility with Drupal 9 only.

This will be addressed when we only support Drupal 9.x.

jrockowitz’s picture

Status: Postponed » Needs review
StatusFileSize
new30.41 KB

I can't seem to be able to open a merge request. Here is the patch.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community

  • jrockowitz authored 45e5093 on 6.2.x
    Issue #3155654 by jrockowitz, awolfey, artis, alberto56: [Drupal 9.x]...
jrockowitz’s picture

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed
jrockowitz’s picture

Version: 6.x-dev » 6.2.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dadderley’s picture

I just encountered this problem.

Drupal version : 10.2.5
Default theme : swz
Admin theme : claro
PHP version : 8.1.27

I have several forms and they all sent email as they should.
The site uses the SMTP module and it works well for email.

Very recently, the existing forms stopped working.

The forms collected data, but showed a 500 error on submission.
There were no SMTP messages indicating a failure or success in the sending of emails.

I came across this thread and This rang a bell

when submitting a form which has an email handler.

This is mitigated by the fact that it is not a good idea to enable devel_generate on production, so this probably won't happen in production, but on dev/stage servers with devel_generate enabled, it will cause fatal errors.

As it turned out, on this site I had left the Devel Generate module installed.

I uninstalled it and the problem immediately disappeared.

lincoln-batsirayi’s picture

I had the same issue as in #49 where we'd left devel_generate enabled on stage and disabling it fixed the issue of the dead screen upon submitting the form.

liam morland’s picture

@#49, @#50: I think the problem you are facing is fixed in #3435903: Fix incompatibility with devel ^5.2.

lbrassaw’s picture

I had the same issue as described in #49 – I uninstalled Devel Generate and the problem disappeared.