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

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

jonasanne created an issue. See original summary.

jonasanne’s picture

Issue summary: View changes
jonasanne’s picture

cilefen’s picture

Priority: Normal » Major
Issue tags: +Needs tests

Indeed, it is true.

juliengui made their first commit to this issue’s fork.

juliengui’s picture

Status: Active » Needs review
Issue tags: -Needs tests +Needs Review Queue Initiative
smustgrave’s picture

Status: Needs review » Needs work

For good practice can we update the issue summary please. Proposed solution should always be filled out at least.

Thanks! Nice work.

juliengui’s picture

Issue summary: View changes
Status: Needs work » Needs review
juliengui’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Needs work

Small 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

lendude made their first commit to this issue’s fork.

lendude’s picture

Status: Needs work » Needs review

Was 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.

yan’s picture

I can confirm that patch from MR 16255 solves the problem for me.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a typo for sure.

jsacksick’s picture

Possibly related, some Commerce tests are failing, attaching the full backtrace:

#0 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(39): Drupal\views\Plugin\views\wizard\WizardPluginBase->__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::Symfony\Component\EventDispatcher\{closure}()
#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/Test/StackMiddleware/TestWaitTerminateMiddleware.php(36): Symfony\Component\HttpKernel\HttpKernel->handle()
#10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware->handle()
#11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(30): Drupal\Core\StackMiddleware\Session->handle()
#12 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#13 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(118): Drupal\Core\StackMiddleware\ContentLength->handle()
#14 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(92): Drupal\page_cache\StackMiddleware\PageCache->pass()
#15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(61): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(54): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#19 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(753): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#20 /var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php(34): Drupal\Core\DrupalKernel->handle()
#21 /var/www/html/vendor/autoload_runtime.php(32): Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
#22 /var/www/html/web/autoload_runtime.php(22): require('...')
#23 /var/www/html/web/index.php(13): require_once('...')
#24 {main}
jsacksick’s picture

Confirmed by a coworker just now, the fix from the MR fixes it.

tbkot’s picture

I've checked the commerce tests with the changes in the MR; the issue is gone, and the tests are passing.

  • godotislate committed 4893eafb on 11.4.x
    fix: #3608733 Ajax error when creating a new content view
    
    By: jonasanne...

  • godotislate committed 703e5974 on 11.x
    fix: #3608733 Ajax error when creating a new content view
    
    By: jonasanne...

  • godotislate committed 77849a93 on main
    fix: #3608733 Ajax error when creating a new content view
    
    By: jonasanne...
godotislate’s picture

Version: main » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Wasn'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!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

uv516 changed the visibility of the branch 3608733-ajax-error-when to active.

uv516’s picture

Hopefully this can be resolved soon