Problem/Motivation
When trying to add a new content based view I get the following error:
ArgumentCountError: Too few arguments to function Drupal\node\Plugin\views\wizard\Node::__construct(), 0 passed in /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php on line 39 and exactly 7 expected in Drupal\node\Plugin\views\wizard\Node->__construct() (regel 68 van /var/www/html/web/core/modules/node/src/Plugin/views/wizard/Node.php)
#0 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(39): Drupal\node\Plugin\views\wizard\Node->__construct()
#1 /var/www/html/web/core/lib/Drupal/Core/Utility/CallableResolver.php(100): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()
#2 /var/www/html/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(77): Drupal\Core\Utility\CallableResolver->getCallableFromDefinition()
#3 /var/www/html/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(112): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse()
#4 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException()
#5 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():241}()
#6 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#7 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(241): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable()
#9 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(30): Drupal\Core\StackMiddleware\Session->handle()
#11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#12 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(61): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(54): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#17 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(753): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#18 /var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php(34): Drupal\Core\DrupalKernel->handle()
#19 /var/www/html/vendor/autoload_runtime.php(32): Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
#20 /var/www/html/web/autoload_runtime.php(22): require('...')
#21 /var/www/html/web/index.php(13): require_once('...')
#22 {main}
I think it's related to [drupal.org issue #3552110](https://www.drupal.org/project/drupal/issues/3552110).
Steps to reproduce
1. `composer create-project drupal/recommended-project my_site_name`
2. Set up the project with Minimal or Standard install profile.
3. Add a basic content type.
4. Go to Views UI.
5. Try to add a view based on Content, and select the newly created content type.
6. See the error 🙂
Proposed resolution
Make ViewsFormAjaxHelperTrait::ajaxUpdateForm() a public static method and change its #ajax callback reference from :ajaxUpdateForm to ::ajaxUpdateForm.
Since #3552110 removed the plugins' manual create() methods, the views wizard plugins (e.g. Node) are no longer container-instantiable. The single-colon callback tried to instantiate the plugin to call the method, invoking its 7-arg constructor with 0 args → ArgumentCountError. A static callback avoids instantiation and fixes the error. Adds a ViewsWizardTest case that changes the "of type" filter via AJAX.
API changes: ajaxUpdateForm() becomes static (flag for reviewers).
Remaining tasks
User interface changes
Introduced terminology
API changes
ajaxUpdateForm() becomes static (flag for reviewers).
Data model changes
Release notes snippet
Issue fork drupal-3608733
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
jonasanne commentedComment #3
jonasanne commentedComment #4
cilefen commentedIndeed, it is true.
Comment #7
juliengui commentedComment #8
smustgrave commentedFor good practice can we update the issue summary please. Proposed solution should always be filled out at least.
Thanks! Nice work.
Comment #9
juliengui commentedComment #10
juliengui commentedComment #11
smustgrave commentedSmall stuff but we should drop assertion messages. Also a link to the issue is not needed as we have git history for that. So if those could be cleaned up please
Comment #13
lendudeWas checking this for review, looks good. Ran the test change without the fix and fails as expected.
Made the requested changes, removed the comment, that information can be found here and removed the message.
Comment #14
yan commentedI can confirm that patch from MR 16255 solves the problem for me.
Comment #15
smustgrave commentedSeems like a typo for sure.
Comment #16
jsacksick commentedPossibly related, some Commerce tests are failing, attaching the full backtrace:
Comment #17
jsacksick commentedConfirmed by a coworker just now, the fix from the MR fixes it.
Comment #18
tbkot commentedI've checked the commerce tests with the changes in the MR; the issue is gone, and the tests are passing.
Comment #23
godotislateWasn't sure about the test, but test only fails as expected: https://git.drupalcode.org/project/drupal/-/jobs/10986202
Committed and pushed to 77849a9 main, 703e597 to 11.x, and 4893eaf to 11.4.x. Thanks!
Comment #26
uv516 commentedHopefully this can be resolved soon