Error: Call to a member function getSetting() on null in Drupal\comment\Controller\CommentController->commentPermalink() (line 125 of core/modules/comment/src/Controller/CommentController.php).

Created on 7 January 2019, almost 6 years ago
Updated 6 September 2024, 2 months ago

My apologies in advance if this is not done correctly. It's my first time submitting an issue, and I wasn't sure what to enter for Issue tags.

Background

Learning Drupal 8 using the book Mastering Drupal 8: An advanced guide to building and maintaining Drupal websites by Chaz Chumley and William Hurley. Currently on page 213: Creating Comments, which illustrates how to generate dummy comments via the Terminal.

Issue

Environment

  • OS: Ubuntu 18.04.1
  • PHP version: 7.1.25-1
  • MySQL version: 5.7.24

Repeatable

Always.

Expected Behaviors

After generating dummy comments via the Terminal drupal console:

Actual Behaviors

After generating dummy comments via the Terminal drupal console:

Steps Taken

  1. In Terminal window, typed drupal create:comments with options 2, 5, 5, and 1. Completed successfully.
  2. In Firefox, went to http://localhost/drupal8/web. Logged in as admin. Completed successfully.
  3. Clicked Manage > Content. Greeted with the following red error message:
             Notice: Undefined index: comment in Drupal\comment\Controller\CommentController->commentPermalink() (line 122 of core/modules/comment/src/Controller/CommentController.php).
    
    Drupal\comment\Controller\CommentController->commentPermalink(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 669)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
         
  4. Clicked Comments tab. Mixed results: I see the same red error message above, but followed by a successful listing of the 5 comments I generated via the Terminal command.
  5. Clicked any of the comment titles to open the pertinent comment record. Greeted with the following error message:

    The website encountered an unexpected error. Please try again later.
    Error: Call to a member function getSetting() on null in Drupal\comment\Controller\CommentController->commentPermalink() (line 125 of core/modules/comment/src/Controller/CommentController.php).

    Drupal\comment\Controller\CommentController->commentPermalink(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 669)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

Other Info

A Google search of the error message revealed this previously closed issue:

Fatal error: Call to a member function getSetting() on a non-object in core/modules/comment/src/Entity/Comment.php on line 531

Could this be somehow related?

Thank you!
Eddie

💬 Support request
Status

Closed: works as designed

Version

11.0 🔥

Component
Comment 

Last updated 2 days ago

Created by

🇺🇸United States mchameddie

Live updates comments and jobs are added and updated live.
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.

  • 🇳🇿New Zealand quietone

    @mchameddie, thanks for reporting this problem. I has taken some time for someone to reply.

    I see from the summary that in step 1, drupal create:comments was used and then you were getting errors related to comments. It is possible that the drupal command did not create the comment correctly. If that is the case, since that command is not part of Drupal core, it is not something we can fix here.

    If the problem can be reproduced on a supported version of Drupal, without using drupal console, provide complete steps to reproduce the issue (starting from "Install Drupal core"). Thanks.

    I don't see a bug here, changing to a support request

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Ranjit1032002

    Created a patch for the issue mentioned, please review.
    Thank You.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States smustgrave

    Moving to PNMI for an answer to #8

  • Status changed to Closed: works as designed 2 months ago
  • 🇳🇿New Zealand quietone

    There has been no discussion here or response to the request for more information in over 1 year.

    The Drupal Core issue queue is not the ideal place for support requests (that option is mostly there for filing support issues for contributed modules and themes). There are several support options listed on our support page (Community > Support at the top of Drupal.org) and there is Drupal Slack . Drupal Slack and the Forums, which are our two main support mechanisms in the Drupal community.

  • 🇧🇬Bulgaria korn3000 Burgas
  • 🇧🇬Bulgaria korn3000 Burgas

    adjusted patch for 10.3x

Production build 0.71.5 2024