i got this error

Notice: Undefined variable: key in comment_prepare_thread() (line 901 of ... /modules/comment/comment.module)

solved by editing comment table in phpmyamdin
i check uid fields some uid numbers not exist and make this error
i fixed them and solved

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dcam’s picture

Priority: Critical » Normal
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: -page break load problem comment +Needs steps to reproduce

You're going to need to give us more info. What steps need to be taken in order to reproduce the problem? Do you have any contributed or custom modules that may be causing the problem? If non-existing uids were the problem, did you recently delete a number of users?

JKingsnorth’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

There was no further response from the original poster so I'm going to close the issue for now. Please do reopen the issue if you still require assistance, with full instructions to recreate the error from a fresh installation of the latest version.

q0rban’s picture

I've seen this happen when users or nodes are deleted from the database, which breaks the relationship between the comment and those tables. comment_load() then fails to load the comment even though there is a row in the comment table.

David_Rothstein’s picture

Version: 7.32 » 7.x-dev
Status: Closed (cannot reproduce) » Active

Haven't tested it myself, but that seems like a reasonable explanation.

Patil_kunal27’s picture

As here we using the $key variable outside the foreach , we need to predefined the $key variable.

David_Rothstein’s picture

Status: Active » Needs work

That looks like it would fix the notice, but probably not the underlying problem - the code is still expecting an actual array of comments to be passed in.

I think the patch at #1451072: Deleting a comment author while the Comment module is disabled leads to an EntityMalformedException error after it's reenabled may actually fix this is a side effect, so perhaps this issue could eventually be closed as a duplicate?

AltaGrade’s picture

Status: Needs work » Closed (duplicate)

We started to see the reported error after enabling the Search 404 module on one of our Drupal 7 projects. Following David's guess in #6 we applied the patch https://www.drupal.org/files/issues/comment-author-deleted-1451072-2-D7.... and the error was gone. So this is to confirm this can be marked as duplicate.