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.
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | 3155654-42.patch | 30.41 KB | jrockowitz |
| #37 | 3155654-37.patch | 668 bytes | artis |
| #29 | 3155654-29.patch | 612 bytes | awolfey |
| #22 | 3155654-22.patch | 37.24 KB | jrockowitz |
| #20 | 3155654-20.patch | 38.07 KB | jrockowitz |
Issue fork webform-3155654
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
Comment #2
alberto56 commentedAccording to @weitzman:
So it seems it is up to Webform to make sure it does not use an incompatible base plugin.
Comment #3
jrockowitz commentedThe 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.
Comment #4
alberto56 commentedThanks! 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:
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.
Comment #5
alberto56 commentedComment #6
jrockowitz commentedI 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.
Comment #7
alberto56 commentedThanks. 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:
* Download webform and devel
* Make sure we have the 2.1 version of devel and the latest version of webform:
* Enable some modules:
* Apply the patch
* Clear all caches for good measure:
* 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.
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:
Here is a partial trace which leads to WebformSubmissionDevelGenerate being autoloaded instead of WebformSubmissionDevelGenerateDeprecated:
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.
Comment #8
jrockowitz commentedI 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.
Comment #9
alberto56 commentedThanks @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
And my composer file is:
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.
Comment #10
alberto56 commentedComment #11
alberto56 commented@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.
Comment #12
jrockowitz commentedPHP 7.4 might be the source of the problem.
BTW, I am testing the default Contact webform.
Comment #13
alberto56 commentedHappens 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:
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?
Comment #14
alberto56 commentedI also did a quick search for WebformSubmissionDevelGenerate in the Webform codebase and found:
So this might need to be fixed elsewhere also.
Comment #15
dom. commentedI 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.
Comment #16
jrockowitz commentedI think the attached patch solves the problem.
Comment #17
jrockowitz commentedComment #18
jrockowitz commentedI am bumping this to critical because it will require an immediate release once the issue is resolved.
Comment #19
alberto56 commented@jrockowitz thanks. The patch says 0 bytes and loads as a blank page for me.
Comment #20
jrockowitz commentedComment #21
alberto56 commentedThis portion of the patch is causing issues for me, is it there by mistake:
I'll set to needs work.
Comment #22
jrockowitz commentedSorry about that.
Comment #23
alberto56 commentedThanks 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?
Comment #26
jrockowitz commentedComment #27
jrockowitz commentedI committed the patch. I will tag a release in the next day or so.
Comment #29
awolfey commentedI found one more incompatibility. Patch attached.
Posting here instead of a new issue for ease of use / search.
Comment #30
jrockowitz commentedComment #33
jrockowitz commentedComment #34
jrockowitz commentedThe patch from #29 caused #3196635: WebformSubmissionDevelGenerate::validateDrushParams($args) must be compatible with Drupal\devel_generate\DevelGenerateBaseInterface::validateDrushParams(array $args, array $options = Array) in Drush 9.x.
For Drush 10.x, the patch from #29 should be included in #3164855: Replace Drush deprecated functions
Comment #36
stijnhau commentedStill had this issue in 6.0.2.
Had to alter patch #29 to get it working
Comment #37
artis commentedrerolled #36 text patch as a file for ease of adding to composer.json
Comment #38
jrockowitz commentedComment #39
jrockowitz commentedHoping that this can addressed via #3220309: [Drupal 9.x] Only support Drush 10 for Drupal 9.x+ and Webform 6.x+
Comment #40
jrockowitz commentedComment #41
jrockowitz commentedThis will be addressed when we only support Drupal 9.x.
Comment #42
jrockowitz commentedI can't seem to be able to open a merge request. Here is the patch.
Comment #43
jrockowitz commentedComment #45
jrockowitz commentedComment #46
jrockowitz commentedComment #47
jrockowitz commentedComment #49
dadderley commentedI just encountered this problem.
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
As it turned out, on this site I had left the Devel Generate module installed.
I uninstalled it and the problem immediately disappeared.
Comment #50
lincoln-batsirayi commentedI 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.
Comment #51
liam morland@#49, @#50: I think the problem you are facing is fixed in #3435903: Fix incompatibility with devel ^5.2.
Comment #52
lbrassaw commentedI had the same issue as described in #49 – I uninstalled Devel Generate and the problem disappeared.
Comment #53
alberto56 commentedRelated to #3447608: Fatal error: Type of Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate::$entityTypeManager must be and #3499830: Move DevelGenerate plugin to a new webform_devel_generate module within this project