When I enable either 'Show "unread messages" status message on user log in?' or 'Show "unread messages" status message on user profile?' setting, I get white screen after login or when going to user's profile, respectively.

Log contains the following error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '<database>.contact_save' doesn't exist: SELECT COUNT(id) FROM contact_save WHERE `read` = 0; Array ( ) in contact_save_unread_messages() (line 163 of <path-to>/sites/all/modules/contact_save/contact_save.module).

I have a prefix set for database tables but it seems that there are two places in the code where Contact Save always tries to SELECT explicitly from the contact_save table.

Attached patch solves the issue.

Comments

leppa’s picture

Issue summary: View changes
StatusFileSize
new1.42 KB
leppa’s picture

Status: Active » Needs review
alex_sansom’s picture

Looks to be an issue due to the combination of table name not being enclosed in '{' and '}' and the use of database table prefix. So, as well as the patch, another approach would be to wrap the table name in curly brackets. Both approaches should work.

See https://www.drupal.org/node/310072

Prefixing

In static queries, all table names must be wrapped in {}. That flags them so that the database system can attach a prefix string to them if appropriate. Prefixing allows for running multiple sites from the same database or, in limited cases, for sharing selected tables between sites.

  • paravibe committed d29c831 on 7.x-1.x authored by leppa
    Issue #2541436 by leppa: PDOException when 'Show "unread messages"...
paravibe’s picture

Status: Needs review » Fixed

Committed! Thanks!

Status: Fixed » Closed (fixed)

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