Cannot output domain source in content view - buildUrl() on null

Created on 21 August 2024, 11 months ago

Drupal Version

10.3.2

Domain module version

2.0.0-beta1+18-dev

Expected Behavior

Show selected domain in view /admin/content

Actual Behavior

Cannot add views field because of the error.

Steps to reproduce

  • Edit view /admin/content
  • Add field Domain Source
Error: Call to a member function buildUrl() on null in Drupal\domain_source\Plugin\views\field\DomainSource->getItems() (Zeile 29 in /web/modules/contrib/domain/domain_source/src/Plugin/views/field/DomainSource.php).
#0 /web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1195): Drupal\domain_source\Plugin\views\field\DomainSource->getItems(Object(Drupal\views\ResultRow))
#1 /web/core/modules/views/views.theme.inc(238): Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object(Drupal\views\ResultRow))
#2 [internal function]: template_preprocess_views_view_field(Array, 'views_view_fiel...', Array)
#3 /web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array('template_prepro...', Array)
#4 /web/core/lib/Drupal/Core/Render/Renderer.php(491): Drupal\Core\Theme\ThemeManager->render('views_view_fiel...', Array)
#5 /web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, false)
#6 /web/core/modules/views/src/Plugin/views/field/FieldPluginBase.php(1796): Drupal\Core\Render\Renderer->render(Array)
#7 /web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(767): Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object(Drupal\views\ResultRow))
#8 [internal function]: Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
#9 /web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array(Array, Array)
#10 /web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#11 /web/core/lib/Drupal/Core/Render/Renderer.php(432): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#12 /web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender(Array, true)
#13 /web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render(Array, true)
#14 /web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#15 /web/core/lib/Drupal/Core/Render/Renderer.php(164): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(709): Drupal\Core\Render\Renderer->renderInIsolation(Array)
#17 /web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(572): Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array)
#18 /web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(460): Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, true)
#19 /web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2177): Drupal\views\Plugin\views\style\StylePluginBase->render()
#20 /web/core/modules/views/src/ViewExecutable.php(1592): Drupal\views\Plugin\views\display\DisplayPluginBase->render()
#21 /web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2467): Drupal\views\ViewExecutable->render()
#22 /web/core/modules/views/src/ViewExecutable.php(1721): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
#23 /web/core/modules/views_ui/src/ViewUI.php(617): Drupal\views\ViewExecutable->preview('page_1', Array)
#24 /web/core/modules/views_ui/src/ViewPreviewForm.php(63): Drupal\views_ui\ViewUI->renderPreview('page_1', Array)
#25 /web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\views_ui\ViewPreviewForm->form(Array, Object(Drupal\Core\Form\FormState))
#26 /web/core/modules/views_ui/src/ViewFormBase.php(42): Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#27 [internal function]: Drupal\views_ui\ViewFormBase->buildForm(Array, Object(Drupal\Core\Form\FormState), 'page_1')
#28 /web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
#29 /web/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm('view_preview_fo...', Object(Drupal\Core\Form\FormState))
#30 /web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('view_preview_fo...', Object(Drupal\Core\Form\FormState), Array)
#31 /web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('view_preview_fo...', Array, Object(Drupal\Core\Form\FormState))
#32 /web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\views_ui\ViewPreviewForm), Object(Drupal\Core\Form\FormState))
#33 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#34 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#35 /web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#36 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#37 /web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#38 /vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#39 /vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#40 /web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#41 /web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#42 /web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#43 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#44 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#45 /web/modules/contrib/shield/src/ShieldMiddleware.php(263): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#46 /web/modules/contrib/shield/src/ShieldMiddleware.php(219): Drupal\shield\ShieldMiddleware->bypass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#47 /web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#48 /web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#49 /web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#50 /web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#51 /web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#52 /web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#53 {main}
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland handkerchief

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @handkerchief
  • πŸ‡¨πŸ‡­Switzerland handkerchief
  • πŸ‡¨πŸ‡­Switzerland handkerchief
  • πŸ‡¨πŸ‡·Costa Rica hjuarez20

    New patch compatible with 2.0.x-dev version

  • πŸ‡©πŸ‡ͺGermany 4kant

    #4 works for me.
    Thanks!

  • πŸ‡¨πŸ‡­Switzerland handkerchief
  • πŸ‡¨πŸ‡­Switzerland handkerchief
  • πŸ‡©πŸ‡ͺGermany webflo
  • Status changed to RTBC 7 months ago
  • πŸ‡·πŸ‡ΊRussia _cosmos_ Izhevsk, Russia

    Thanks for patch

  • πŸ‡ΊπŸ‡ΈUnited States fizcs3 Omaha, Nebraska; USA

    Just ran into this. Basically added a Domain Source value to a bunch of content, then tried to display that field in a view and got WSOD.
    FYI the WDLog came up with three messages, which I'll preface:

    • Warning: Undefined array key "#options" in Drupal\domain_source\Plugin\views\field\DomainSource->getItems() (line 27 of /app/web/modules/contrib/domain/domain_source/src/Plugin/views/field/DomainSource.php)
    • Warning: Trying to access array offset on null in Drupal\domain_source\Plugin\views\field\DomainSource->getItems() (line 27 of /app/web/modules/contrib/domain/domain_source/src/Plugin/views/field/DomainSource.php)
    • Error: Call to a member function buildUrl() on null in Drupal\domain_source\Plugin\views\field\DomainSource->getItems() (line 29 of /app/web/modules/contrib/domain/domain_source/src/Plugin/views/field/DomainSource.php).

    The last being the Error that this issue is based on...

    Patch #4 fixed it for me, moving ahead again thankfully.
    Patch applied successfully on Drupal 10.3.11, PHP 8.3.x, domain 2.0.0-beta2.

  • πŸ‡§πŸ‡ͺBelgium flyke

    A client of us ran into this problem on a Drupal 11.1.7 project: He could not reach /admin/content?type=showroom (yes the project has a 'Showroom' content type and uses the domain module. The domain is shown in the admin/content view). He could not open the page, it was a white screen with the message: The website encountered an eunexpected error. Try again later. When read his email the next day and I tested the page opened without problem. So I could not replicate it. Also on my local dev version: no problem. But when I looked at the status reports of around the time when the client sent the email, there was the error:

    Error: Call to a member function buildUrl() on null in Drupal\domain_access\Plugin\views\field\DomainAccessField->getItems() (regel 31 van /data/sites/web/henradeu/releases/3/web/modules/contrib/domain/domain_access/src/Plugin/views/field/DomainAccessField.php).

    This patch applied. I hope it fixed the problem as I cant be 100% certain as I could not replicate the problem myself.

  • πŸ‡«πŸ‡·France mably

    Could someone open a MR on 2.0.x please?

  • Pipeline finished with Success
    about 1 month ago
    Total: 228s
    #509585
  • πŸ‡ΊπŸ‡ΈUnited States fizcs3 Omaha, Nebraska; USA

    Opened MR!148 above that is the same as patch in #4.
    Moved to Needs review status.

  • πŸ‡«πŸ‡·France mably

    I have added a few comments to the MR.

  • Pipeline finished with Success
    about 1 month ago
    Total: 276s
    #511205
  • πŸ‡ΊπŸ‡ΈUnited States fizcs3 Omaha, Nebraska; USA

    @mably Thank you for your review and thoughts. I added another commit to MR!148 with your suggested tweaks to code in both the getItems and sort functions, which make sense.
    Now in views, the Domain Source field's result does show up as a link as well.
    Moving back to Needs review for any further review.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024