I have a site recently moved from D6 to D7. The search in D7 was not finding nodes containing the search terms, so I began a re-index in the search settings. This has stalled at 11% of site (with 3570 items left to index), and running cron does nothing to advance the re-index.

The log messages show that when cron runs, it encounters this error:

EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7766 of /var/www/html/[domain]/includes/common.inc).

And this notice:

Notice: Undefined variable: key in comment_prepare_thread() (line 901 of /var/www/html/[domain]/modules/comment/comment.module).

Also, there are many instances of this notice, which is associated with use of the site, not cron:

Undefined index: weblinks in custom_search_form_alter() (line 232 of /var/www/html/[domain]/sites/all/modules/custom_search/custom_search.module).

None of these seem to affect the function of the site, and it's not clear to me that they are actually related to the stalled re-indexing. But it's all I've got to go on at this point.

If anyone could give me some ideas for how to troubleshoot this, I'd very much appreciate it.


2 Answers 2


This problem was caused by discussion forum posts with a single comment from a user whose id was no longer in the user table (threads with more than one comment, even though one was from an invalid user id, did not cause the error).

The fix was to find comments with invalid user ids, then change those ids in the Comment table to 0.

This SQL query identified the problem user ids:

SELECT DISTINCT a.uid FROM comment a left join users b on a.uid = b.uid 

With the problem user ids identified, you can either edit the table directly, or use UPDATE to change the column values.

With those values changed in the comment table, the re-indexing proceeded to 100% without a hitch.

  • Thanks so much for this help! For the list of bad comments, SELECT c1.cid FROM comment c1 WHERE c1.uid IN (SELECT DISTINCT c.uid FROM comment c LEFT JOIN users u ON c.uid = u.uid WHERE u.uid IS NULL); then to fix the bad comments take the list you just got back and issue something like this (put your own cids in there): UPDATE comment SET uid=0 WHERE cid in (25, 53, 115);
    – rfay
    Commented Sep 19, 2015 at 22:58

If you have installed Drush in your root directory, then you can run the below command to begin a re-index in the search settings.

drush search-reindex

To rebuild the index immediately, instead of waiting for cron, please execute the below command.

drush search-reindex --immediate

This will bring upto 100% reindexing of a website.

  • Yes, you can do this, but it also fails on the bad nodes.
    – BHammond
    Commented Nov 20, 2015 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.