After enabling the dlike Module, anyone who has not the standard DB table layout (i.ex. because of using table-prefixes) will get an error:

WD php: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb.system' doesn't exist: SELECT weight FROM system WHERE name = :flag; Array                                                           [error]
(
    [:flag] => flag
)
 in dlike_enable() (line 15 of /srv/www/myhost/www/public_html/sites/all/modules/dlike/dlike.install).

/srv/www/myhost/www/public_html/includes/bootstrap.inc).
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydb.system' doesn't exist: SELECT weight FROM system WHERE name = :flag; Array
(
    [:flag] => flag
)
 in dlike_enable() (line 15 of /srv/www/myhost/www/public_html/sites/all/modules/dlike/dlike.install).

This is because dlike is using the table name "system" in dbquery, without putting in brackets ({}).
Putting the table name in brackets, like: {system} fixed this issue.

Patch-Code:

15c15
<   $flag_weight = db_query('SELECT weight FROM system WHERE name = :flag', array(':flag' => 'flag'))->fetchField();
---
>   $flag_weight = db_query('SELECT weight FROM {system} WHERE name = :flag', array(':flag' => 'flag'))->fetchField();

Comments

svarco’s picture

Issue summary: View changes

replaced host name and db name with generic values

svarco’s picture

Issue summary: View changes

another replacemanet

kenneth.venken’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new552 bytes

Can confirm this. Attached is the above patch-code in patch form.

fotuzlab’s picture

Thanks svarco for pointing out. Some loose coding here :(

@kenneth. Thanks for the patch, but I think you have put the braces at the wrong place. :)
Would you like to resubmit it?

kevin.klika’s picture

Status: Reviewed & tested by the community » Needs work

Confirmed the problem and the solution, the patch is incorrect, however.

kenneth.venken’s picture

Status: Needs work » Needs review
StatusFileSize
new587 bytes

@fotuzlab: One line, one mistake. Not my best patch ;)

Retry...

fotuzlab’s picture

Status: Needs review » Fixed

Committed to dev. Attributed to svarco.
Appreciate the contribution from kenneth.venken

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

typos