CommentManager::getCountNewComments() : PHP error on user activity and recent content view

Created on 24 October 2016, about 8 years ago
Updated 22 April 2024, 7 months ago

I get an PHP error in my error_log with the CommentManager::getCountNewComments() function, on user activity view /user/activity/uid and recent content view /activity.

This error come up on a Drupal 8.2.0 version that is actualy in use in production with many modules installed (Nginx server) :

2016/10/24 11:47:37 [error] 15222#15222: *281253 FastCGI sent in stderr: "PHP message: TypeError: Argument 1 passed to Drupal\comment\CommentManager::getCountNewComments() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /var/www/html/drupal/core/modules/comment/src/Controller/CommentController.php on line 330 in /var/www/html/drupal/core/modules/comment/src/CommentManager.php on line 190 #0 /var/www/html/drupal/core/modules/comment/src/Controller/CommentController.php(330): Drupal\comment\CommentManager->getCountNewComments(NULL)
#1 [internal function]: Drupal\comment\Controller\CommentController->renderNewCommentsNodeLinks(Object(Symfony\Component\HttpFoundation\Request))
#2 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#3 /var/www/html/drupal/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#4 /var/www/html/drupal/core/lib/Dr" while reading response header from upstream, client: 55.137.231.152, server: website.fr, request: "POST /comments/render_new_comments_node_links HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "website.fr", referrer: "http://website.fr/activity"

So trying to reproduce this on a fresh new basic installation and get similar error on a Drupal 8.2.1 version (apache server) :

Recoverable fatal error: Argument 1 passed to Drupal\\comment\\CommentManager::getCountNewComments() must implement interface Drupal\\Core\\Entity\\EntityInterface, null given, called in /var/www/html/drupal/core/modules/comment/src/Controller/CommentController.php on line 330 and defined in /var/www/html/drupal/core/modules/comment/src/CommentManager.php on line 190 #0 /var/www/html/drupal/core/includes/bootstrap.inc(548): _drupal_error_handler_real(4096, 'Argument 1 pass...', '/var/www/html/d...', 190, Array)
#1 /var/www/html/drupal/core/modules/comment/src/CommentManager.php(190): _drupal_error_handler(4096, 'Argument 1 pass...', '/var/www/html/d...', 190, Array)
#2 /var/www/html/drupal/core/modules/comment/src/Controller/CommentController.php(330): Drupal\\comment\\CommentManager->getCountNewComments(NULL)#3 [internal function]: Drupal\\comment\\Controller\\CommentController->renderNewCommentsNodeLinks(Object(Symfony\\Component\\HttpFoundation\\Request))#4 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#5 /var/www/html/drupal/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()
#6 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext(Object(Drupal\\Core\\Render\\RenderContext), Object(Closure))
#7 /var/www/html/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#8 [internal function]: Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()
#9 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(139): call_user_func_array(Object(Closure), Array)
#10 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(62): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)
#11 /var/www/html/d8_sandbox/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#12 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#13 /var/www/html/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#14 /var/www/html/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#15 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#16 /var/www/html/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#17 /var/www/html/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#18 /var/www/html/drupal/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)
#19 /var/www/html/drupal/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))
#20 {main}, referer: http://devdruplocal:8004/activity/1
🐛 Bug report
Status

Postponed

Version

1.0

Component
Tracker 

Last updated 6 months ago

No maintainer
Created by

🇫🇷France geoffvio

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024