Problem/Motivation
Previewing the "default" view mode shows PHP notices, e.g.
https://www.example.com/node/2/view-mode/preview/default
shows:
Notice: Undefined index: default in Drupal\view_modes_display\Controller\PreviewController->previewEntity() (line 95 of modules/contrib/view_modes_display/src/Controller/PreviewController.php).
Notice: Undefined index: default in Drupal\view_modes_display\Controller\PreviewController->previewEntity() (line 95 of modules/contrib/view_modes_display/src/Controller/PreviewController.php).
Drupal\view_modes_display\Controller\PreviewController->previewEntity(Object, 'node')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Notice: Trying to access array offset on value of type null in Drupal\view_modes_display\Controller\PreviewController->previewEntity() (line 95 of modules/contrib/view_modes_display/src/Controller/PreviewController.php).
Drupal\view_modes_display\Controller\PreviewController->previewEntity(Object, 'node')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
See above
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | notice-on-default-preview-3305680-2.patch | 944 bytes | fathima.asmat |
Comments
Comment #2
fathima.asmat commentedPatch attached.
Comment #3
fathima.asmat commentedComment #4
anybodyThanks @fathima.asmat. Could you please provide this as MR and elaborate (from core perhaps or backtrace) under which conditions
may not be set?
Does core have similar logics as you wrote?
Comment #5
zach.bimson commentedThanks @fathima.asmat for the patch!
@Anybody i think the underlying issue here is that we are fetching a list of all entity view display config but for the preview page we are taking the name of the display and trying to find it in the view modes which are inherently different... going to merge the patch in to the latest dev 3.x to get rid of this warning and explore deeper.
Comment #7
zach.bimson commentedComment #8
zach.bimson commentedReleased in `3.0.0`