The getUnreadThreadCount method throws SQLSTATE[42702] sql errror

Created on 25 June 2024, 6 months ago
Updated 7 September 2024, 4 months ago

Problem/Motivation

While rendering notification block, it's attempt to fetch the unread messages info thru the ajax, but fails with 500, which is cased by sql error
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "id" is ambiguous LINE 18: GROUP BY "id") "subquery" ^: SELECT COUNT(*) AS "expression" FROM (SELECT "thread"."id" AS "id", 1 AS "expression" FROM "private_messages" "message" INNER JOIN "private_message_thread__private_messages" "thread_message" ON message.id = thread_message.private_messages_target_id INNER JOIN "private_message_threads" "thread" ON thread_message.entity_id = thread.id INNER JOIN "pm_thread_history" "thread_history" ON thread_history.thread_id = thread.id AND thread_history.access_timestamp < thread.updated AND thread_history.uid = :uid INNER JOIN "private_message_thread__members" "thread_member" ON thread_member.entity_id = thread.id AND thread_member.members_target_id = :uid WHERE ("thread"."updated" > :db_condition_placeholder_0) AND ("message"."created" > :db_condition_placeholder_1) AND ("message"."owner" <> :db_condition_placeholder_2) AND ("thread"."id" NOT IN (SELECT "thread_member"."entity_id" AS "entity_id" FROM "private_message_thread__members" "thread_member" WHERE "thread_member"."members_target_id" IN (SELECT "pmb"."target" AS "target" FROM "private_message_ban" "pmb" WHERE "pmb"."owner" = :db_condition_placeholder_3) GROUP BY "entity_id")) GROUP BY "id") "subquery"; Array ( [:db_condition_placeholder_0] => 1618585412 [:db_condition_placeholder_1] => 1618585412 [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => 1 [:uid] => 1 ) in Drupal\private_message\Mapper\PrivateMessageMapper->getUnreadThreadCount()

Steps to reproduce

Place the notifications block to be rendered, update a thread and check does the the block contains any info about new unread messages

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine myLies

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024