Problem/Motivation
Steps to reproduce
Install a fresh Drupal 10.4 site
Install Views reference field and views reference field filter modules
Generate some articles
Create a content type (e.g. test) with a views reference field "view1" and enable the "exposed filters - editors view" checkbox
Create a simple view listing the articles with some exposed filters e.g. author, published etc.
Add a node of the new content type test
Add the view to a node in the "view1" field
Select a display (This fails sometimes - see https://www.drupal.org/project/viewsreference/issues/3497201 although there is now a patch that fixes it. )
Save the node
Edit the node
Change the value in one of the exposed filters
Save the node
Notice the WSOD and error message:
The website encountered an unexpected error. Try again later.
TypeError: Drupal\views\ViewExecutableFactory::get(): Argument #1 ($view) must be of type Drupal\views\ViewEntityInterface, null given, called in /var/www/html/web/modules/contrib/viewsreference_filter/src/ViewsRefFilterUtility.php on line 63 in Drupal\views\ViewExecutableFactory->get() (line 77 of core/modules/views/src/ViewExecutableFactory.php).
Drupal\viewsreference_filter\ViewsRefFilterUtility->loadView() (Line: 68)
Drupal\viewsreference_filter\Plugin\ViewsReferenceSetting\ViewsReferenceExposedFilters->alterFormField() (Line: 175)
Drupal\viewsreference\Plugin\Field\FieldWidget\ViewsReferenceWidget->fieldElement() (Line: 31)
Drupal\viewsreference\Plugin\Field\FieldWidget\ViewsReferenceWidget->formElement() (Line: 459)
Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 219)
Drupal\Core\Field\WidgetBase->formMultipleElements() (Line: 120)
Drupal\Core\Field\WidgetBase->form() (Line: 190)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form() (Line: 134)
Drupal\node\NodeForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | empty-options1.png | 41.72 KB | selwynpolit |
Issue fork viewsreference_filter-3497737
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:
- 3497737-
changes, plain diff MR !11
Comments
Comment #2
selwynpolit commentedComment #3
selwynpolit commentedComment #4
pheudo commentedHi @selwynpolit,
I have difficulties replicating the issue you opened.
Could you please verify if the issue is still present with the 1.0.6 version?
Comment #5
pheudo commentedComment #6
selwynpolit commentedThanks for taking a look. I did retest with version 1.0.6 and I get the same results. I do have the views reference extras module enabled. I'll try it again without that.
Comment #7
selwynpolit commentedThat doesn't seem to make any difference. I updated to the latest and greatest of everything, deleted the view reference field and created a new one. Then I tried to edit some content. Just enabling the checkbox "Show Filters on Page" and saving the node caused the error.
Is it a known bug that the first time you select a view and select a display, that the options don't show anything?
Comment #8
pheudo commentedComment #9
amarshkhl09 commentedI have come across a similar issue after updating to Drupal 10.4.x. However upon troubleshooting this, it doesn't seem to be from the Drupal core or the Views Reference Field Filter module but rather from the Views Reference module - https://www.drupal.org/project/viewsreference. Downgrading it to 2.0@beta8 fixed the issue for me, but the Filter module probably needs to be updated to be compatible with the latest Views Reference update.
Comment #10
jsweetack commentedHave this same issue after updating to 10.3.9, with Layout Paragraphs, only for a certain paragraph type, and it results in an AJAX error in the console, preventing any saving of the paragraph.
Downgrading to 2.0-beta8 works, thanks to @amarshkhl09 for figuring that out.
Is there a proper fix for this in the works?
Comment #11
bburgI am also experiencing this, with the 1.0.6 version of this module, and 2.0-beta10 of viewsreference. In my case, I have views reference fields in a paragraph type, which are loaded from a general paragraph field with unlimited cardinality.
For one, I think it we can make the code safer in ViewsRefFilterUtility::loadView() by checking that it's not null/empty later after we try to load the view when we detect that it's empty. Since we declare that variable static right before this line, I think it would always be true since it will be "set", but in this case, seems to have no value.
Adding a "&& !empty($view)" right before
to resolve the error for me. Though I'm still not sure why it's happening. After running some tests in xdebug, I do see that subsequent attempts to add an additional view embed field via paragraph type appears to try to load the view with the Human readable label instead of the view's machine name. e.g. $view_name = "My View" instead of "my_view"
This is a bit complicated, but the problem seems to be somewhere in ViewsReferenceTrait::itemCurrentValues() in the viewsreference module. This seems to be where we sometimes get the view label in lieu of the machine name, around here:
Comment #14
carlitus commentedCreated a MR to check if the view name it's not _none. In my case this resolves this issue.
Comment #15
pheudo commentedComment #16
pheudo commented