- Issue created by @jungle
- Merge request !152Edge case: $entity_type_id might be empty in group_query_entity_query_alter() → (Open) created by jungle
- Status changed to Needs review
8 months ago 1:30pm 15 April 2024 - Status changed to RTBC
8 months ago 7:23am 16 April 2024 - 🇮🇳India abhishek_virasat
cloned the issue from above mentioned version, and tested locally. above MR fixed the issue. moving RTBC++
- 🇧🇪Belgium JeroenT 🇧🇪
I had the same problem. I can also confirm the MR fixes this issue.
- 🇺🇦Ukraine _tarik_ Lutsk
Thanks, the solution works for me as well
Here is the patch adaptation for group 8.x-1.x version - Status changed to Active
5 months ago 10:52am 26 June 2024 - 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium
The problem is that when you get to that function all queries should have the right metadata. We've previously had an incompatibility with VBO because it stripped important metadata from queries. So my advice would be to see what the CSV export module is doing to the Views query.
- 🇬🇷Greece vensires
I started writing this comment in the next issue but I see it to be more fit here.
I tried using the code in #2797565-8: Correct way to programmatically get $total_rows for a View → for some reason I fell into this one. The view I use doesn't have any issues getting executed since I have it also as a page display and on that page it's working correctly.Just for clearance, the original code proposed in that issue is the following:
/** * This is the failing code. */ use Drupal\views\Views; $view = Views::getView('export_patient_csv'); $view->build('patient'); $q = $view->query->query()->countQuery()->execute()->fetchAssoc(); $count = reset($q); dpm($count, '$view->query->query()->countQuery()->execute()->fetchAssoc()');
or for the last line:
$total_rows = $view->query->query()->countQuery()->execute()->fetchField();
When doing the above, I had the exception of this issue. What did work in my case though was the following:
/** * This is the working code. */ $view = Views::getView('view_id'); $view->setDisplay('display_id'); $view->setArguments([...$args]); $view->get_total_rows = TRUE; $view->execute(); $total_rows = $view->total_rows;
As far as I checked the views module line by line, the
\Drupal\views\Plugin\views\query\Sql::build()
method wasn't getting executed. May it be related to the fact that ingroup_views_query_alter()
you do the following?// Build the Views query already so we can access the DB query. $query->build($view); $view->built = TRUE;
- 🇬🇷Greece vensires
To add to my last comment, since you mentioned the
views_data_export
module, it's working correctly when exporting data directly. When I tried to use the Batch mode though, it failed with this issue's bug. The only solution for my case was to setdisable_sql_rewrite
toTRUE
for that display and then it worked. It was an admin view so it wasn't such a big deal in terms of security but definitely some things get awkward due to this functionality in the group module.