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 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
Comment | File | Size | Author |
---|---|---|---|
#5 | Undefined_variable_key_in_comment_prepare_thread-2363369-5.patch | 431 bytes | Patil_kunal27 |
Comments
Comment #1
dcam CreditAttribution: dcam commentedYou'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?
Comment #2
JKingsnorth CreditAttribution: JKingsnorth commentedThere 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.
Comment #3
q0rban CreditAttribution: q0rban at Lullabot for Cisco Systems commentedI'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.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedHaven't tested it myself, but that seems like a reasonable explanation.
Comment #5
Patil_kunal27 CreditAttribution: Patil_kunal27 as a volunteer and at Intelliswift commentedAs here we using the $key variable outside the foreach , we need to predefined the $key variable.
Comment #6
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThat 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?
Comment #7
AltaGrade CreditAttribution: AltaGrade commentedWe 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.