Issue #3485498: Fix PHP exception in activity visibility filter related to views join #4159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem (for internal)
Now I see a PHP Exception in Activity stream notifications for anonymous users when I go by URL - /activities/streams/notifications
Drupal\\Core\\Database\\DatabaseExceptionWrapper: Exception in Activity stream notifications[activity_stream_notifications]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.entity_id'
Solution (for internal)
The error says:
Column not found: 1054 Unknown column 'node_field_data.entity_id' in 'on clause'
If I perform
DESCRIBE node_field_data
for my local install then I get next:MariaDB [main]> DESCRIBE node_field_data;
You can see the entity_id column indeed doesn’t exist on this install either, but the table does look exactly like expected.
The field that the query is actually looking for is nid. So the question is why it’s trying to select
entity_id
and notnid
. That’s usually caused by some code not respecting the entity key mapping but hardcodingentity_id
. That’s controlled by the following part of the entity annotationsThe problem in
ActivityNotificationVisibilityAccess.php
As you can see we try to join to
node_field_data
table, but field in$configuration
isentity_id
which not exist innode_field_data
table. So, we need to add the new field to$configuration
, so I should be:So, now we join to table by correct field, and error should be disseapear
Release notes (to customers)
Fix PHP exception related to ActivityNotificationVisibilityAccess filter for anonymous users
Issue tracker
https://www.drupal.org/project/social/issues/3485498
Theme issue tracker
N/A
How to test
/activities/streams/notifications
from anonymous userChange Record
N/A
Translations
N/A