- π³πΏNew Zealand quietone New Zealand
@ pviquez@pabloviquez.com, Thank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.
Is this issue still a problem?
There has been no activity here for 5 years (not counting the reroll) when a maintainer asked for steps to reproduce. See #20.
If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete
Since we need more information to move forward with this issue, I am setting the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
- π©πͺGermany keinstein
I just came across this issue with 9.5.x. so it is still active.
@Lendude The root cause for this bug is that the object is left in an invalid internal state. Everything else depends on this bug. Either the triggering code is not fixed because the error is accepted by
assignEntitiesToResult
or several functions incore/modules/views/src/Plugin/views/query/Sql.php
are broken and shoudl be fixed that the invalid state is correct.A short scan over my Drupal installations reveals that it's nearly impossible to decide what is intended.
Here are the results:$ grep -e '_relationship_entities' -r .|grep -v test ./core/modules/views/src/ResultRow.php: public $_relationship_entities = []; ./core/modules/views/src/ResultRow.php: * Resets the _entity and _relationship_entities properties. ./core/modules/views/src/ResultRow.php: $this->_relationship_entities = []; ./core/modules/views/src/Plugin/views/cache/CachePluginBase.php: if (!empty($row->_relationship_entities)) { ./core/modules/views/src/Plugin/views/cache/CachePluginBase.php: foreach ($row->_relationship_entities as $key => $entity) { ./core/modules/views/src/Plugin/views/cache/CachePluginBase.php: $row_data = array_diff_key((array) $row, array_flip(['index', '_entity', '_relationship_entities'])) + $this->getRowCacheTags($row); ./core/modules/views/src/Plugin/views/field/FieldPluginBase.php: elseif (isset($values->_relationship_entities[$relationship_id])) { ./core/modules/views/src/Plugin/views/field/FieldPluginBase.php: return $values->_relationship_entities[$relationship_id]; ./core/modules/views/src/Plugin/views/query/QueryPluginBase.php: * $result->_relationship_entities[$relationship_id]; ./core/modules/views/src/Plugin/views/query/Sql.php: * $result->_relationship_entities[$relationship_id]; ./core/modules/views/src/Plugin/views/query/Sql.php: $results[$index]->_relationship_entities[$relationship_id] = $entity; ./core/modules/views/src/Plugin/views/query/Sql.php: foreach ($row->_relationship_entities as $entity) {
As you can see
_relationship_entities
is a public member. So CachePluginBase Sql.php cannot rely on non-null entries in _relationship_entities. So my suggestion is:- In the next major release: Throw an exception if an entity is not valid in
assignEntitiesToResult
- In all other releases issue a warning instead and silently accept the invalid state without crashing in
getAllEntities
Currently code must always check that a certain key contains no null value. With the fix in place people must check that the key exists. What you prefer is a question of coding style and which one is faster depends on the actual application.
- In the next major release: Throw an exception if an entity is not valid in
- π¦πΊAustralia gordon Melbourne
This problem seems to be related to #2738051 π \Drupal\views\Plugin\views\query\Sql::getCacheTags and getCacheMaxAge don't take into account that some entities can be NULL Needs work , but in my case the other didn't fix my issue but caused another issue, and this one fixed it. They both seem to be a very similar issue and solved in slightly different methods.