http://drupal.org/project/karma

I'm hoping to use this for 5.2, however there are sql errors.

   * user warning: Table 'my_database.comments' doesn't exist query: SELECT COUNT(*) FROM comments c LEFT JOIN karma_objects ko ON ko.id = c.cid AND ko.type = 'cid' LEFT JOIN karma_users ku ON ku.uid = c.uid WHERE (ko.rating >= 0 OR (ko.rating IS NULL AND (ku.karma >= 0 OR ku.karma IS NULL))) AND c.nid = 1 in /my/site/includes/database.mysql.inc on line 172.

    * user warning: Table 'my_database.comments' doesn't exist query: SELECT COUNT(*) FROM comments c LEFT JOIN karma_objects ko ON ko.id = c.cid AND ko.type = 'cid' LEFT JOIN karma_users ku ON ku.uid = c.uid WHERE (ko.rating >= 0 OR (ko.rating IS NULL AND (ku.karma >= 0 OR ku.karma IS NULL))) AND c.nid = 1 in /my/site/includes/database.mysql.inc on line 172.

Granted the above page does say 5.1 & not 5.2, which is what I'm using, is there an easy fix for this so I can implement it? Overall it looks good, so I'd like to keep it. Just can't with the sql errors popping up.

Comments

cog.rusty’s picture

The missing 'comments' table should have been created during Drupal installation. Hmm... or should you enable the comment module first in /admin/build/modules ? Try it.

Where does it say 5.1? If you mean karma-5.x-1.x don't mind that, the second part is the module's own version and it doesn't have anything to do with core versions. All 5.x modules are for all 5.x core versions except if they say otherwise.

Seneschall’s picture

Comment 5.2 Allows users to comment on and discuss published content.
Required by: Forum (enabled), Tracker (enabled)

If you mean THIS one, it's definitely activated.

Maybe the configuration of comments doesn't match what Karma is looking for?

cog.rusty’s picture

If you can post comments then the 'comments' table exists. It was created from /modules/system/system.install (you can see the CREATE TABLE {comments} statement there) and it is used by the comments module (you can see the INSERT INTO {comments} statements in the /modules/comment/comment.module file)

It is not a matter of configuration, because the error message just says "table doesn't exist"

So the question is why it isn't finding it. Are you using a table name prefix (such as dru_comments)?

------------ Edit:

Probably this is it: I see in karma.module that it is using "SELECT COUNT(*) FROM comments" and not "SELECT COUNT(*) FROM {comments}" which would get the prefix. It has this bug in other queries as well.

Seneschall’s picture

so it's just a matter of rewriting the code a bit.

will see what I can do...

Cheers,

Eric

cog.rusty’s picture

Yes, it is in 2 places near the end of the file. Search for "from comments" and change

SELECT DISTINCT(nid) FROM comments to SELECT DISTINCT(nid) FROM {comments}

and also

FROM comments c LEFT JOIN karma_objects to FROM {comments} c LEFT JOIN {karma_objects}

It is a good idea to post an issue in http://drupal.org/project/issues/karma to tell them that some table prefix braces are missing from karma.module, so that they fix it.

Seneschall’s picture

will do. Cheers again, cog.rusty!