- 🇧🇷Brazil igoragatti
I have come across this error on a client's website.
Steps to reproduce:
- Enable multisite and address module
- Add address field onto a content type (make field translatable)
- Create a content and translate it to another language
- Add the address field content to both languages
- Remove the address field content from the original language
- Create a view listing the address fields on the translated language
- 🇨🇦Canada danrod Ottawa
Interesting, I reported this a while ago and forgot about it, I'll look into this again just for fun.
- Status changed to RTBC
3 months ago 1:30pm 17 January 2025 - 🇨🇦Canada danrod Ottawa
Hey @igoragatti I tried your steps in in the 2.0.x branch and I couldn't see the issue again, I see that you tested on the release 8.x-1.8, could you upgrade to the latest 2.0.x release? If not it would be nice if the patch goes in the next 8.x-1.x release (if it's still maintained)
- 🇧🇪Belgium kenowax Mons
I'm having this issue on my project using version 2.0.2.
Not sure exactly which steps could be taken to reproduce it yet.Here's the exact error message :
Message Error: Call to a member function getLocality() on null in Drupal\address\Plugin\views\field\Subdivision->render() (line 103 of /var/www/html/web/modules/contrib/address/src/Plugin/views/field/Subdivision.php). Severity Error Hostname 10.63.252.6 Operations Backtrace #0 /var/www/html/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1202): Drupal\address\Plugin\views\field\Subdivision->render() #1 /var/www/html/web/core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender() #2 [internal function]: template_preprocess_views_view_field() #3 /var/www/html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array() #4 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render() #5 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender() #6 /var/www/html/web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1796): Drupal\Core\Render\Renderer->render() #7 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(769): Drupal\views\Plugin\views\field\FieldPluginBase->theme() #8 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow() #9 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array() #10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback() #11 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback() #12 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender() #13 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(708): Drupal\Core\Render\Renderer->render() #14 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(574): Drupal\views\Plugin\views\style\StylePluginBase->renderFields() #15 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(465): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping() #16 /var/www/html/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2177): Drupal\views\Plugin\views\style\StylePluginBase->render() #17 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1593): Drupal\views\Plugin\views\display\DisplayPluginBase->render() #18 /var/www/html/web/core/modules/views/src/Plugin/views/display/Page.php(201): Drupal\views\ViewExecutable->render() #19 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1690): Drupal\views\Plugin\views\display\Page->execute() #20 /var/www/html/web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay() #21 [internal function]: Drupal\views\Element\View::preRenderViewElement() #22 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array() #23 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback() #24 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback() #25 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender() #26 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render() #27 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() #28 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(239): Drupal\Core\Render\Renderer->executeInRenderContext() #29 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare() #30 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() #31 /var/www/html/web/modules/contrib/tracer/src/EventDispatcher/TraceableEventDispatcher.php(97): Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() #32 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\tracer\EventDispatcher\TraceableEventDispatcher->dispatch() #33 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #34 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #35 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #36 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #37 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle() #38 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle() #39 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #40 /var/www/html/vendor/asm89/stack-cors/src/Cors.php(53): Drupal\page_cache\StackMiddleware\PageCache->handle() #41 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle() #42 /var/www/html/web/modules/contrib/tracer/src/StackMiddleware/TracesMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #43 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\tracer\StackMiddleware\TracesMiddleware->handle() #44 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #45 /var/www/html/web/modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\AjaxPageState->handle() #46 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() #47 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #48 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle() #49 {main}
- 🇧🇪Belgium kenowax Mons
After checking branch 2.1.x, I see that no null checks are made on the ItemList->first() function which, contrary to documentation, can return null. This is found in /src/Plugin/views/field/Subdivision.php
The error occurs when trying to access a view page having an address field.
Most probably, the data I have came from some Migrate import, which could explain why not all fields were filled in.I suggest adding null-handling in the code.