Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have created new Display mode for the User Profile and it is rendered by "Views" blocks on the Articles page. Some content doesn't map with the User reference. In that scenario, I am getting undefined error.
Notice: Undefined property: Drupal\views\ViewExecutable::$result in Drupal\views\Plugin\views\query\Sql->getAllEntities() (line 1703 of core/modules/views/src/Plugin/views/query/Sql.php).
Drupal\views\Plugin\views\query\Sql->getAllEntities() (Line: 1676)
Drupal\views\Plugin\views\query\Sql->getCacheTags() (Line: 250)
Drupal\views\Plugin\views\cache\CachePluginBase->getCacheTags() (Line: 1566)
Drupal\views\ViewExecutable->getCacheTags() (Line: 2208)
Drupal\views\Plugin\views\display\DisplayPluginBase->applyDisplayCacheabilityMetadata(Array) (Line: 2183)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1533)
Drupal\views\ViewExecutable->render() (Line: 204)
Drupal\axelerant_blocks\Plugin\Block\UserProfileBlock->renderView('user_profile_name_designation_sbio_pic', Array, Array) (Line: 100)
Drupal\axelerant_blocks\Plugin\Block\UserProfileBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', 'silenced_deprecation', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 222)
__TwigTemplate_25d39c79d9ad7d3603a431a0b745d7a82e5cf4be62efefde51ef3788a8cdc63c->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 60)
__TwigTemplate_e25beabb432e561ec32aa724c2a83865711a068f88c4ee4b61cee245839edb17->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 434)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/axe/templates/content/node--content.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel-
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff_2-7.txt | 615 bytes | rajandro |
#7 | undefined_property-3155815-7.patch | 964 bytes | rajandro |
| |||
#2 | Undefined_property_3155815.patch | 894 bytes | arulan_pari |
Screenshot 2020-06-30 at 3.09.39 PM.png | 356.04 KB | arulan_pari | |
Screenshot 2020-06-30 at 3.09.39 PM.png | 356.04 KB | arulan_pari |
Comments
Comment #2
arulan_pari CreditAttribution: arulan_pari at Axelerant for Drupal India Association commentedPlease, Review my patch and I have tested in my local and its working fine.
Comment #3
arulan_pari CreditAttribution: arulan_pari at Axelerant for Drupal India Association commentedComment #4
arulan_pari CreditAttribution: arulan_pari at Axelerant for Drupal India Association commentedComment #5
mayurjadhav CreditAttribution: mayurjadhav at Srijan | A Material+ Company commentedPatch looks good for me, But Needs to add $row->_relationship_entities inside if condition.
Comment #6
rajandro CreditAttribution: rajandro as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedworking on it.
Comment #7
rajandro CreditAttribution: rajandro as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedAddressed #5, now it should not display any notice for both the scenarios, please review.
Comment #12
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
This will need a test case to show the issue.
Did not test for the problem.
Comment #13
danflanagan8I strongly think this should be closed. The
ViewExecutable::$result
property is clearly typehinted as an array of ResultRows and is initiated as an empty array:I ran into a project that's using this patch because it has some ill-advised custom code that calls
unset($view->result)
in a pre_render hook. In my case, the bug is not in core; the bug is that I have custom code that is unsetting a property that is clearly declared as an array and should never be null. That's "illegal" and should be expected to have ugly side-effects.I highly suspect that any codebase that requires this patch is similarly doing something it shouldn't be doing.
At the very least, this needs steps to reproduce that demonstrate there's some way to trigger this error without first doing something "illegal". I'm adding that tag.
But probably this should be closed as "won't fix".