After updating to 8.x-5.0-rc14, I'm getting:

# drush updb -y
The following updates are pending:

webform module : 
  8123 -   Issue #2962442: Remove [webform-authenticated-user] token and use [current-user] token with clear value option. 
  8124 -   Issue #2971207: Hidden Field updated values not being captured on Submit. 
  8125 -   Issue #2966507: Start-to-finish documentation for showing Webforms in modals. 
  8126 -   Issue #2973377: Make the previously saved messages customizable. 
  8127 -   Issue #2974597: Enable default publishing status of new webforms. 
  8128 -   Issue #2932893: Filter out closed forms in webform field. 
  8129 -   Issue #2977378: Add 'exclude unselected checkboxes' from email notification and preview. 

Do you wish to run all pending updates? (y/n): y
Performing webform_update_8123                                       [ok]
Performing webform_update_8124                                       [ok]
Performing webform_update_8125                                       [ok]
Performing webform_update_8126                                       [ok]
Performing webform_update_8127                                       [ok]
Performing webform_update_8128                                       [ok]
TypeError: Argument 1 passed to                                      [error]
Drupal\webform\WebformTokenManager::__construct() must implement
interface Drupal\Core\Session\AccountInterface, instance of
Drupal\Core\Config\ConfigFactory given, called in
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php
on line 274 in Drupal\webform\WebformTokenManager->__construct()
(line 57 of
/var/www/html/modules/webform/src/WebformTokenManager.php) #0
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(274):
Drupal\webform\WebformTokenManager->__construct(Object(Drupal\Core\Config\ConfigFactory),
Object(Drupal\Core\Extension\ModuleHandler),
Object(Drupal\Core\Theme\ThemeManager), Object(Drupal\token\Token))
#1
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
Drupal\Component\DependencyInjection\Container->createService(Array,
'webform.token_m...')
#2
/var/www/html/modules/webform/src/Plugin/WebformHandler/EmailWebformHandler.php(159):
Drupal\Component\DependencyInjection\Container->get('webform.token_m...')
#3
/var/www/html/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21):
Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::create(Object(Drupal\Core\DependencyInjection\Container),
Array, 'email', Array)
#4
/var/www/html/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(76):
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('email',
Array)
#5
/var/www/html/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php(81):
Drupal\Component\Plugin\PluginManagerBase->createInstance('email',
Array)
#6
/var/www/html/modules/webform/src/Plugin/WebformHandlerPluginCollection.php(30):
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin('email')
#7
/var/www/html/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php(80):
Drupal\webform\Plugin\WebformHandlerPluginCollection->initializePlugin('email')
#8
/var/www/html/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php(148):
Drupal\Component\Plugin\LazyPluginCollection->get('email')
#9 /var/www/html/modules/webform/src/Entity/Webform.php(2077):
Drupal\Component\Plugin\LazyPluginCollection->getIterator()
#10 /var/www/html/modules/webform/includes/webform.install.inc(167):
Drupal\webform\Entity\Webform->getHandlers()
#11
/var/www/html/modules/webform/includes/webform.install.update.inc(2261):
_webform_update_webform_handler_configuration('Drupal\\webform\\...')
#12
/root/.composer/vendor/drush/drush/commands/core/drupal/update.inc(60):
webform_update_8129(Array)
#13
/root/.composer/vendor/drush/drush/commands/core/drupal/batch.inc(163):
drush_update_do_one('webform', 8129, Array,
Object(DrushBatchContext))
#14
/root/.composer/vendor/drush/drush/commands/core/drupal/batch.inc(111):
_drush_batch_worker()
#15 /root/.composer/vendor/drush/drush/includes/batch.inc(98):
_drush_batch_command('25213')
#16
/root/.composer/vendor/drush/drush/commands/core/drupal/update.inc(230):
drush_batch_command('25213')
#17
/root/.composer/vendor/drush/drush/commands/core/core.drush.inc(1227):
_update_batch_command('25213')
#18 /root/.composer/vendor/drush/drush/includes/command.inc(422):
drush_core_updatedb_batch_process('25213')
#19 /root/.composer/vendor/drush/drush/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#20 /root/.composer/vendor/drush/drush/includes/command.inc(199):
drush_command('25213')
#21
/root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#22 /root/.composer/vendor/drush/drush/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#23 /root/.composer/vendor/drush/drush/drush.php(12): drush_main()
#24 {main}.
TypeError: Argument 1 passed to Drupal\webform\WebformTokenManager::__construct() must implement interface Drupal\Core\Session\AccountInterface, instance of Drupal\Core\Config\ConfigFactory given, called in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 274 in /var/www/html/modules/webform/src/WebformTokenManager.php on line 57 #0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(274): Drupal\webform\WebformTokenManager->__construct(Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Extension\ModuleHandler), Object(Drupal\Core\Theme\ThemeManager), Object(Drupal\token\Token))
#1 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, 'webform.token_m...')
#2 /var/www/html/modules/webform/src/Plugin/WebformHandler/EmailWebformHandler.php(159): Drupal\Component\DependencyInjection\Container->get('webform.token_m...')
#3 /var/www/html/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::create(Object(Drupal\Core\DependencyInjection\Container), Array, 'email', Array)
#4 /var/www/html/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(76): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('email', Array)
#5 /var/www/html/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php(81): Drupal\Component\Plugin\PluginManagerBase->createInstance('email', Array)
#6 /var/www/html/modules/webform/src/Plugin/WebformHandlerPluginCollection.php(30): Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin('email')
#7 /var/www/html/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php(80): Drupal\webform\Plugin\WebformHandlerPluginCollection->initializePlugin('email')
#8 /var/www/html/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php(148): Drupal\Component\Plugin\LazyPluginCollection->get('email')
#9 /var/www/html/modules/webform/src/Entity/Webform.php(2077): Drupal\Component\Plugin\LazyPluginCollection->getIterator()
#10 /var/www/html/modules/webform/includes/webform.install.inc(167): Drupal\webform\Entity\Webform->getHandlers()
#11 /var/www/html/modules/webform/includes/webform.install.update.inc(2261): _webform_update_webform_handler_configuration('Drupal\\webform\\...')
#12 /root/.composer/vendor/drush/drush/commands/core/drupal/update.inc(60): webform_update_8129(Array)
#13 /root/.composer/vendor/drush/drush/commands/core/drupal/batch.inc(163): drush_update_do_one('webform', 8129, Array, Object(DrushBatchContext))
#14 /root/.composer/vendor/drush/drush/commands/core/drupal/batch.inc(111): _drush_batch_worker()
#15 /root/.composer/vendor/drush/drush/includes/batch.inc(98): _drush_batch_command('25213')
#16 /root/.composer/vendor/drush/drush/commands/core/drupal/update.inc(230): drush_batch_command('25213')
#17 /root/.composer/vendor/drush/drush/commands/core/core.drush.inc(1227): _update_batch_command('25213')
#18 /root/.composer/vendor/drush/drush/includes/command.inc(422): drush_core_updatedb_batch_process('25213')
#19 /root/.composer/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#20 /root/.composer/vendor/drush/drush/includes/command.inc(199): drush_command('25213')
#21 /root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#22 /root/.composer/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#23 /root/.composer/vendor/drush/drush/drush.php(12): drush_main()
#24 {main}
TypeError: Argument 1 passed to Drupal\webform\WebformTokenManager::__construct() must implement interface Drupal\Core\Session\AccountInterface, instance of Drupal\Core\Config\ConfigFactory given, called in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 274 in Drupal\webform\WebformTokenManager->__construct() (line 57 of /var/www/html/modules/webform/src/WebformTokenManager.php).

Running drush updb -y again results in:

# drush updb -y 
The following updates are pending:

webform module : 
  8129 -   Issue #2977378: Add 'exclude unselected checkboxes' from email notification and preview. 

Do you wish to run all pending updates? (y/n): y
Performing webform_update_8129                                                                          [ok]

# drush updb -y
No database updates required                                                                            [success]
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alberto56 created an issue. See original summary.

jrockowitz’s picture

Can try to clear your cache before running the updates.

alberto56’s picture

I'm confirming that my update script was not clearing the cache prior to running updb; I have added drush cr prior to drush updb -y in my script for future use. My database is now updated on all my instances so I can't confirm that that would fix the issue, though, but thanks for the tip!

jrockowitz’s picture

Priority: Normal » Major
Status: Active » Needs work

What is bizarre is that drush should be clearing the caching before these update hooks are executed.

I have never seen any module having to manually clear the cache before database updates.

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
449 bytes

I can't reproduce this issue.

My best guess is the call to_webform_update_webform_handler_configuration() is triggering the error.

Please try the attached patch but make sure NOT clear your cache when you switch to rc14.

jrockowitz’s picture

Here are my steps attempting to reproduce this issue.

  • Checkout rc12 git checkout 8.x-5.0-rc12
  • Do a full reinstall with webform
  • Goto to the webform manage page (/admin/structure/webform)
  • Confirm that all forms are visible
  • Checkout rc14 git checkout 8.x-5.0-rc14.
  • Execute drush updb
  • Confirm all update hooks are executed
  • Goto to the webform manage page (/admin/structure/webform)
  • Confirm that all forms are visible

Notes

  • Executed above step using Drush 8 and 9.
jrockowitz’s picture

What version of Drush are you running?

drush --version

alberto56’s picture

I managed to reproduce this:

(1) use this version of Drush (not sure it makes a difference)

# drush --version
 Drush Version   :  8.1.17 

(2) brand new Drupal 8 site with token and webform 8.x-5.0-rc12
(3) drush en -y webform_ui token
(4) go to /admin/structure/webform/manage/contact/handlers/email_confirmation/edit
(5) in "to mail", put Custom To Mail Address, and put "[webform_submission:created]"
(6) drush cex -y # Export the config
(7) drush dl -y webform-8.x-5.0-rc14
(8) drush updb -y

jrockowitz’s picture

@alberto56 Does the patch fix the issue?

I think I have to rewrite _webform_update_webform_handler_configuration().

alberto56’s picture

Yes, if I apply the patch between steps 7 and 8, the error no longer happens:

webform module : 
  8123 -   Issue #2962442: Remove [webform-authenticated-user] token and use [current-user] token with clear value option. 
  8124 -   Issue #2971207: Hidden Field updated values not being captured on Submit. 
  8125 -   Issue #2966507: Start-to-finish documentation for showing Webforms in modals. 
  8126 -   Issue #2973377: Make the previously saved messages customizable. 
  8127 -   Issue #2974597: Enable default publishing status of new webforms. 
  8128 -   Issue #2932893: Filter out closed forms in webform field. 
  8129 -   Issue #2977378: Add 'exclude unselected checkboxes' from email notification and preview. 

Do you wish to run all pending updates? (y/n): y
Performing webform_update_8123                                       [ok]
Performing webform_update_8124                                       [ok]
Performing webform_update_8125                                       [ok]
Performing webform_update_8126                                       [ok]
Performing webform_update_8127                                       [ok]
Performing webform_update_8128                                       [ok]
Performing webform_update_8129                                       [ok]
Cache rebuild complete.                                              [ok]
Finished performing updates.                                         [ok]
root@29da6212ef3c:/var/www/html# 

jrockowitz’s picture

Using #8 I can replicate the issue.

Instead of executing drush updb, which clears the cache, we can use the below command to continuously replicate the issue.

drush php-eval 'module_load_include('install', 'webform'); webform_update_8129()';

jrockowitz’s picture

@alberto56 Please review the attached patch.

alberto56’s picture

Status: Needs review » Reviewed & tested by the community

I tested this patch using the steps at #8 and with the patch, everything works fine, but without the patch I get the error. I will tentatively set this to RTBC with the caveat that I don't fully understand what's at play here, I just can say it works!

Thanks for your time on this.

jrockowitz’s picture

I think this might be a Drush specific issue because if I follow the steps from #8 but for (8) instead of executing drush updb -y, I open /update.php and execute the pending updates everything is fine.

I am not seeing anyone else having this issue but the Webform module relies on a lot of services with dependency injections and changes to service definitions during an update is causing this issue.

johnny5th’s picture

Running drush php-eval 'module_load_include('install', 'webform'); webform_update_8129()'; fixed my database after the failed update from rc12 to rc14. 90% of my webforms were missing before running that.

jrockowitz’s picture

The key function/update that needs to be triggered is _webform_update_webform_settings(); which is included in webform_update_8128() and webform_update_8129().

You can also run drush webform-repair which executes _webform_update_webform_settings();

jrockowitz’s picture

jrockowitz’s picture

Since this is a core issue, implementing a temporary workaround seems like a reasonable solution.

The attached patch executes \Drupal::service('kernel')->rebuildContainer(); before any calls are made to webform.* services.

  • jrockowitz committed 0c454c4 on 8.x-5.x
    Issue #2977856 by jrockowitz: hook_update_8129() causing typeError on...
jrockowitz’s picture

I committed the patch. Please download the latest dev release to review.

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

garrettw’s picture

When updating webform from rc12 to rc15 today (drupal 8.5.4, drush 8.1.16) I got the following similar error:

Performing webform_update_8128                                                                                                                                                                                                                       [ok]
Argument 1 passed to Drupal\webform\WebformTokenManager::__construct() must implement interface Drupal\Core\Session\AccountInterface, instance of Drupal\Core\Config\ConfigFactory given, called in                                                  [error]
/app/core/lib/Drupal/Component/DependencyInjection/Container.php on line 274 and defined WebformTokenManager.php:57
Argument 2 passed to Drupal\webform\WebformTokenManager::__construct() must implement interface Drupal\Core\Config\ConfigFactoryInterface, instance of Drupal\Core\Extension\ModuleHandler given, called in                                          [error]
/app/core/lib/Drupal/Component/DependencyInjection/Container.php on line 274 and defined WebformTokenManager.php:57
Argument 3 passed to Drupal\webform\WebformTokenManager::__construct() must implement interface Drupal\Core\Extension\ModuleHandlerInterface, instance of Drupal\Core\Theme\ThemeManager given, called in                                            [error]
/app/core/lib/Drupal/Component/DependencyInjection/Container.php on line 274 and defined WebformTokenManager.php:57
PHP Fatal error:  Call to undefined method Drupal\Core\Extension\ModuleHandler::get() in /app/modules/webform/src/WebformTokenManager.php on line 63
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/drush:0
PHP   2. require() /usr/local/bin/drush:10
PHP   3. drush_startup() phar:///usr/local/bin/drush/drush:114
PHP   4. drush_run_main() phar:///usr/local/bin/drush/includes/startup.inc:369
PHP   5. drush_main() phar:///usr/local/bin/drush/includes/startup.inc:462
PHP   6. Drush\Boot\BaseBoot->bootstrap_and_dispatch() phar:///usr/local/bin/drush/includes/preflight.inc:66
PHP   7. drush_dispatch() phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php:67
PHP   8. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:199}() phar:///usr/local/bin/drush/includes/command.inc:199
PHP   9. drush_command() phar:///usr/local/bin/drush/includes/command.inc:199
PHP  10. _drush_invoke_hooks() phar:///usr/local/bin/drush/includes/command.inc:231
PHP  11. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:422}() phar:///usr/local/bin/drush/includes/command.inc:422
PHP  12. drush_core_updatedb_batch_process() phar:///usr/local/bin/drush/includes/command.inc:422
PHP  13. _update_batch_command() phar:///usr/local/bin/drush/commands/core/core.drush.inc:1227
PHP  14. drush_batch_command() phar:///usr/local/bin/drush/commands/core/drupal/update.inc:230
PHP  15. _drush_batch_command() phar:///usr/local/bin/drush/includes/batch.inc:98
PHP  16. _drush_batch_worker() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:111
PHP  17. call_user_func_array:{phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163}() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163
PHP  18. drush_update_do_one() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163
PHP  19. webform_update_8129() phar:///usr/local/bin/drush/commands/core/drupal/update.inc:60
PHP  20. _webform_update_webform_handler_settings() /app/modules/webform/includes/webform.install.update.inc:2273
PHP  21. Drupal\Component\Plugin\PluginManagerBase->createInstance() /app/modules/webform/includes/webform.install.inc:159
PHP  22. Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() /app/core/lib/Drupal/Component/Plugin/PluginManagerBase.php:76
PHP  23. Drupal\webform\Plugin\WebformHandler\SettingsWebformHandler::create() /app/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php:21
PHP  24. Drupal\Component\DependencyInjection\Container->get() /app/modules/webform/src/Plugin/WebformHandler/SettingsWebformHandler.php:70
PHP  25. Drupal\Component\DependencyInjection\Container->createService() /app/core/lib/Drupal/Component/DependencyInjection/Container.php:171
PHP  26. Drupal\webform\WebformTokenManager->__construct() /app/core/lib/Drupal/Component/DependencyInjection/Container.php:274

Fatal error: Call to undefined method Drupal\Core\Extension\ModuleHandler::get() in /app/modules/webform/src/WebformTokenManager.php on line 63

Call Stack:
    0.0022     227184   1. {main}() /usr/local/bin/drush:0
    0.0169     626632   2. require('phar:///usr/local/bin/drush/drush') /usr/local/bin/drush:10
    0.0174     693824   3. drush_startup() phar:///usr/local/bin/drush/drush:114
    0.0227     695832   4. drush_run_main() phar:///usr/local/bin/drush/includes/startup.inc:369
    0.0241     869208   5. drush_main() phar:///usr/local/bin/drush/includes/startup.inc:462
    0.5838   11431584   6. Drush\Boot\BaseBoot->bootstrap_and_dispatch() phar:///usr/local/bin/drush/includes/preflight.inc:66
    0.8058   11810064   7. drush_dispatch() phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php:67
    0.9205   14785136   8. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:199}() phar:///usr/local/bin/drush/includes/command.inc:199
    0.9205   14785656   9. drush_command() phar:///usr/local/bin/drush/includes/command.inc:199
    0.9240   14837264  10. _drush_invoke_hooks() phar:///usr/local/bin/drush/includes/command.inc:231
    0.9416   15175544  11. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:422}() phar:///usr/local/bin/drush/includes/command.inc:422
    0.9416   15175912  12. drush_core_updatedb_batch_process() phar:///usr/local/bin/drush/includes/command.inc:422
    0.9439   15374320  13. _update_batch_command() phar:///usr/local/bin/drush/commands/core/core.drush.inc:1227
    1.4425   24255912  14. drush_batch_command() phar:///usr/local/bin/drush/commands/core/drupal/update.inc:230
    1.4461   24402568  15. _drush_batch_command() phar:///usr/local/bin/drush/includes/batch.inc:98
    1.4491   24409880  16. _drush_batch_worker() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:111
    2.8911   40815832  17. call_user_func_array:{phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163}() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163
    2.8911   40815880  18. drush_update_do_one() phar:///usr/local/bin/drush/commands/core/drupal/batch.inc:163
    2.8918   40817480  19. webform_update_8129() phar:///usr/local/bin/drush/commands/core/drupal/update.inc:60
    3.3161   41346736  20. _webform_update_webform_handler_settings() /app/modules/webform/includes/webform.install.update.inc:2273
    3.6547   45953120  21. Drupal\Component\Plugin\PluginManagerBase->createInstance() /app/modules/webform/includes/webform.install.inc:159
    3.6547   45953256  22. Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() /app/core/lib/Drupal/Component/Plugin/PluginManagerBase.php:76
    3.6571   46082496  23. Drupal\webform\Plugin\WebformHandler\SettingsWebformHandler::create() /app/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php:21
    3.6571   46082840  24. Drupal\Component\DependencyInjection\Container->get() /app/modules/webform/src/Plugin/WebformHandler/SettingsWebformHandler.php:70
    3.6572   46088568  25. Drupal\Component\DependencyInjection\Container->createService() /app/core/lib/Drupal/Component/DependencyInjection/Container.php:171
    3.7268   46829536  26. Drupal\webform\WebformTokenManager->__construct() /app/core/lib/Drupal/Component/DependencyInjection/Container.php:274

Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                   [error]
Error: Call to undefined method Drupal\Core\Extension\ModuleHandler::get() in /app/modules/webform/src/WebformTokenManager.php, line 63
The external command could not be executed due to an application error.                                                                                                                                                                              [error]
Cache rebuild complete.                                                                                                                                                                                                                              [ok]
Finished performing updates.                                                                                                                                                                                                                         [ok]

Naturally, running drush updb after that worked fine.