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

Comments

geoffvio created an issue. See original summary.

larowlan’s picture

Component: comment.module » tracker.module
Issue tags: +Needs tests

Those pages are provided by tracker module

zoltán balogh’s picture

Here too...

zoltán balogh’s picture

Version: 8.2.0 » 8.7.3

In the current Drupal release, this bug exists yet.

larowlan’s picture

Version: 8.7.3 » 8.7.x-dev
rkostov’s picture

my way to solve this

rkostov’s picture

Status: Active » Needs review

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

commonColby’s picture

#6 Worked for me.

Drupal 8.8.6

pavnish’s picture

StatusFileSize
new1.84 KB

@commonColby Hi the patch is also working for 8.9.X but not working for 9.1.x so re-roll the patch
Please review the patch for 9.1.x

Thanks
Pavnish

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

raman.b’s picture

StatusFileSize
new3.07 KB
new1.56 KB

We need to update the ES6 file and run yarn build:js

raman.b’s picture

Status: Needs review » Needs work

NW for tests

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
hilly510’s picture

StatusFileSize
new3.23 KB
new4.69 KB

Re-roll patch for 9.3.x. The interdiff wouldn't generate so I attached a reroll diff.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ao5357’s picture

StatusFileSize
new3.3 KB

Re-roll patch for 9.5.x

Abhisheksingh27’s picture

Status: Needs work » Needs review
StatusFileSize
new3.6 KB

Uploading #19 for 9.5.x patch after fixing CCF.

pooja saraah’s picture

StatusFileSize
new3.44 KB
new3.31 KB

Fixed failed commands on #20
Attached patch against Drupal 9.5.x

ameymudras’s picture

StatusFileSize
new3.46 KB
new1.41 KB
quietone’s picture

Status: Needs review » Postponed

This extension is deprecated and scheduled for removal in Drupal 11.

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to the contributed extension once the Drupal 11 branch is open.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Project: Drupal core » Activity Tracker
Version: 11.x-dev » 1.0.x-dev
Component: tracker.module » Code

not sure it still reproducible but now in contrib