Problem/Motivation
Fatal PHP Fatal error: Call to a member function getEntity() on a non-object in /var/www/drupal-8/core/modules/comment/src/CommentAccessControlHandler.php on line 61
Steps to reproduce.
- Create a comments view with a rest display on path /comments
- Add relation to it's node with node id from url
- Is preview working?
- Is page in browser working?
- Is
curl --user admin:admin --header 'Accept: application/json' --request GET http://drupal.d8/comments
- Change Row style from Entity to Fields
- Repeat the checks above
Proposed resolution
Remaining tasks
User interface changes
API changes
Original report by @MartijnBraam
Got this error on a view with rest export for comments filtered by node. The view works if format is "Entity" but not with "Fields".
[Wed Sep 24 14:12:31.021783 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP Fatal error: Call to a member function getEntity() on a non-object in /var/www/drupal-8/core/modules/comment/src/CommentAccessControlHandler.php on line 61
[Wed Sep 24 14:12:31.021880 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP Stack trace:
[Wed Sep 24 14:12:31.021918 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 1. {main}() /var/www/drupal-8/index.php:0
[Wed Sep 24 14:12:31.021943 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 2. Drupal\\Core\\DrupalKernel->handle() /var/www/drupal-8/index.php:22
[Wed Sep 24 14:12:31.021977 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 3. Stack\\StackedHttpKernel->handle() /var/www/drupal-8/core/lib/Drupal/Core/DrupalKernel.php:567
[Wed Sep 24 14:12:31.021990 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 4. Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle() /var/www/drupal-8/core/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
[Wed Sep 24 14:12:31.021998 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 5. Drupal\\Core\\StackMiddleware\\PageCache->handle() /var/www/drupal-8/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:58
[Wed Sep 24 14:12:31.022010 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 6. Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle() /var/www/drupal-8/core/lib/Drupal/Core/StackMiddleware/PageCache.php:52
[Wed Sep 24 14:12:31.022016 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 7. Symfony\\Component\\HttpKernel\\HttpKernel->handle() /var/www/drupal-8/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:53
[Wed Sep 24 14:12:31.022032 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 8. Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw() /var/www/drupal-8/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:66
[Wed Sep 24 14:12:31.022046 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 9. call_user_func_array() /var/www/drupal-8/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:126
[Wed Sep 24 14:12:31.022059 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 10. Drupal\\views\\Routing\\ViewPageController->handle() /var/www/drupal-8/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:126
[Wed Sep 24 14:12:31.022071 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 11. Drupal\\views\\ViewExecutable->initHandlers() /var/www/drupal-8/core/modules/views/src/Routing/ViewPageController.php:82
[Wed Sep 24 14:12:31.022083 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 12. Drupal\\views\\ViewExecutable->_initHandler() /var/www/drupal-8/core/modules/views/src/ViewExecutable.php:787
[Wed Sep 24 14:12:31.022095 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 13. Drupal\\field\\Plugin\\views\\field\\Field->access() /var/www/drupal-8/core/modules/views/src/ViewExecutable.php:903
[Wed Sep 24 14:12:31.022107 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 14. Drupal\\Core\\Entity\\EntityAccessControlHandler->fieldAccess() /var/www/drupal-8/core/modules/field/src/Plugin/views/field/Field.php:217
[Wed Sep 24 14:12:31.022120 2014] [:error] [pid 13325] [client 127.0.0.1:46271] PHP 15. Drupal\\comment\\CommentAccessControlHandler->checkFieldAccess() /var/www/drupal-8/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php:297