ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: badmonkey on January 01, 2017, 11:01:11 pm

Title: 1.1b4 database error with unread
Post by: badmonkey on January 01, 2017, 11:01:11 pm
It doesn't happen to every member.  My account doesn't seem to have the issue.  A test account doesn't either.  Others seem to be having it.  From the ACP error log:


Code: [Select]

    Type of error: General
    Please try again. If you come back to this error screen, report the error to an administrator.

  /index.php?action=unreadreplies

    File: /public_html/sources/database/Db-mysql.class.php
    Line: 679

----------------------------------------------------------------------------------------------


    Type of error: Database
    Database Error: Unknown column 'lt.unwatched' in 'where clause'


    SELECT t.id_topic
    FROM elk_topics_posted_in AS t
    LEFT JOIN elk_log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic)
    WHERE t.id_board IN (1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37)
    AND COALESCE(lt.id_msg, t.id_msg) < t.id_last_msg AND COALESCE(lt.unwatched, 0) != 1
    ORDER BY t.id_last_msg DESC
    LIMIT 0, 20

   /index.php?action=unreadreplies

    /public_html/sources/subs/Unread.class.php
    Line: 402



Title: Re: 1.1b4 database error with unread
Post by: emanuele on January 02, 2017, 08:05:51 am
Bug.
Try opening Unread.class.php (in sources/subs) and find:
Code: [Select]
				WHERE t.id_board IN ({array_int:boards})
AND COALESCE(lt.id_msg, t.id_msg) < t.id_last_msg' .
($this->_post_mod ? ' AND t.approved = {int:is_approved}' : '') .
($this->_unwatch ? ' AND COALESCE(lt.unwatched, 0) != 1' : '') . '
ORDER BY {raw:order}
at about line 392 and replace it with:
Code: [Select]
				WHERE t.id_board IN ({array_int:boards})
AND COALESCE(lt.id_msg, t.id_msg) < t.id_last_msg
ORDER BY {raw:order}
this should do. :)