I am using Drupal 10.1.2 version with PHP 8.1.24.
I have imported users and content from Drupal 7 to Drupal 10 by feeds. When working in Drupal 10 I have noticed that it is showing error when I am using views with user relationships. When opening admin/reports/dblog, the error is showing.
Error: Call to a member function getCacheMaxAge() on null in Drupal\views\Plugin\views\query\Sql->getCacheMaxAge() (line 1710 of /...../..../.../core/modules/views/src/Plugin/views/query/Sql.php).
Can anyone please let me know how to solve the issue?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3401468-views-fix-empty-missed-entities-relationship.patch | 838 bytes | p.kasianov |
Comments
Comment #2
cilefen commentedWould you please obtain the stack trace and explain to us how to configure a view that shows this bug?
Comment #3
mjgruta commentedHi @Sandip, we had similar issues but we upgraded from Drupal 8 to 10. in our case, the user id 0 was missing in the users table. I just created one and it seems to work fine now.
Comment #5
inversed commentedI'm also experiencing this on a new build and I'm wondering how this issue happened. This post's comment provides a patch but I'd like to understand the underlying cause.
https://www.drupal.org/forum/support/post-installation/2019-12-23/unexpe...
Comment #6
inversed commentedI found this which provides a possible explanation for how UID 0 is lost, what it does, and how to restore it:
https://www.drupal.org/docs/administering-a-drupal-site/troubleshooting-...
Comment #7
p.kasianov commentedPatch for d 10.3
I remove from index of results the record of missed entity and add log message with details.
It doesnt fix the reason of missed entity, but fix fatal + provide more details of it.
Comment #8
p.kasianov commentedPatch file
Comment #9
p.kasianov commentedUpdated log message
Comment #10
p.kasianov commentedSome update why this fatal error was happens.
Views gets result from database table, but when views trying to load entites in loadEntities (fucntion) it doesnt gets all entities. In my case the reason was in uncorectrly removed record of entity. Finnaly, it returned NULL, and get tryed to get maxCache from NULL.
If you will debug it, you see that in the assignEntitiesToResult function need to skip NULL and remove item from the result list.
The best solution as for me - it checks for empty on query level. But the perfomance will down.
Comment #11
p.kasianov commentedUpdated the name (Added issue number).
Comment #12
batkorThank @inversed .
Need create anonymous user. https://www.drupal.org/docs/administering-a-drupal-site/troubleshooting-...
Comment #13
smustgrave commentedThis was previously tagged for steps to reproduce, which appear to still be needed. If not provided this could be closed out.
Comment #14
batkorMy steps to reproduce.
I migrate users from Yii1.
After migrate in my drupal DB removed|lost anonymous user.