Problem/Motivation
Steps to reproduce:
1. edit who_s_new view at admin/structure/views/view/who_s_new
2. add relationship "User: Content authored"
3. add filter criteria "Content: Type"
After clicking the button "Add and configure filter criteria" nothing happens. Reloading the page gives an error page "The website has encountered an error. Please try again later.". Dblog shows two errors: "Notice: Trying to get property of non-object in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 706 of /home/s881b53b46578b78/www/core/modules/views/src/Plugin/views/HandlerBase.php)." and "Exception: No entity type for field type on view who_s_new in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 716 of /home/s881b53b46578b78/www/core/modules/views/src/Plugin/views/HandlerBase.php)."
Proposed resolution
Remaining tasks
User interface changes
API changes
Original report by @username
Goal: Filter nodes based on the current user attributes which has the same term in nodes.
This error shows when adding "Content type" in filter area of views.
Uncaught PHP Exception Exception: "No entity type for field type on view test_announcement" at /var/www/drupal8/core/modules/views/src/Plugin/views/HandlerBase.php line 770
Beta phase evaluation
Issue category | Bug: Relationships can't be properly configured in the UI/td> |
---|---|
Issue priority | Major, because its a key functionality of views, but its not a broken site for everyone |
Disruption | No disruption, just internal fixes. |
Comment | File | Size | Author |
---|---|---|---|
#20 | 2322457-20.patch | 4.15 KB | pcambra |
#17 | interdiff.txt | 2.08 KB | olli |
#17 | 2322457-17.patch | 4.11 KB | olli |
#15 | 2322457-15.patch | 2.86 KB | andypost |
#5 | 2322457-5.patch | 2.93 KB | olli |
Comments
Comment #1
dawehnerIt would be kind of cool if you could provide an export of that view. This seems to be no straightforward view to rebuild.
Comment #2
adrian.ravis CreditAttribution: adrian.ravis commentedI can't get the export data of the view. When I apply the "Content type" in filter it hangs only in image "2_2.png" that I provided. I tried to reload it but it returns "Error: The website has encountered an error. Please try again later" and I've tried it many times.
Comment #3
dawehnerWell, please enable error display under "logging and errors" under admin/config
Comment #4
olli CreditAttribution: olli commentedI was able to reproduce this by adding a content view with a relationship using field_tags and then tried to add a vocabulary filter. I can't edit my view anymore.
Error
The website has encountered an error. Please try again later.
Error message
Notice: Trying to get property of non-object in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 760 of core/modules/views/src/Plugin/views/HandlerBase.php).
Exception: No entity type for field vid on view bundletest in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 770 of core/modules/views/src/Plugin/views/HandlerBase.php).
Comment #5
olli CreditAttribution: olli commentedHere's a patch that uses this->table instead of this->view->relationships which are not available.
Comment #9
olli CreditAttribution: olli commentedAdded steps to reproduce to issue summary.
Comment #10
13rac1 CreditAttribution: 13rac1 commentedYes. This fixes the issue and applies cleanly. I can edit a View with a broken handler now!
Comment #11
dawehnerAre we really sure this is the proper fix? $this->table could point to something like node_field_data, which might or might not have 'entity type' on there.
Using the base tables (which is what the previous code did, feels much more secure.
Afaik we could also fix this issue by using
$this->view->relationship[$relationship_name]->table
instead.Comment #12
alexpottSetting back to "needs review" to get answers to #11
Comment #13
olli CreditAttribution: olli commented#11: Good points.
Isn't it the same problem with base tables?
That was my first thought but this method is invoked from an init() and having relationship[X]->table ready sounded like the init() of that relationship should be called before this one so went with something simple.
Comment #14
andypostThe same problems with related issue - I need to find the relation that used for the handler so
This does not work for related, it returns "comment_entity_statistics" but I need to know the entity type of the relation
Comment #15
andypostSuppose the proper fix as said #13
Comment #17
olli CreditAttribution: olli commentedMaybe this?
Comment #20
pcambraPlain re roll of this, fixes the problem described with the relationships and filters.
Comment #21
dawehnerNice work!
Comment #22
alexpottCommitted f51b029 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.