- Issue created by @psaleks
- 🇨🇦Canada psaleks
Problem with incorrect optimization in EntityReference_SelectionHandler_Views.class.php. v7.x-1.8
line 142$target_type = $this->field['settings']['target_type']; // Do not load the entire entity for performance reasons. $entity_info = entity_get_info($target_type); $query = db_select($entity_info['base table'], 'e'); $query->fields('e'); $query->condition('e.' . $entity_info['entity keys']['id'], array_keys($result), 'IN'); foreach ($query->execute() as $entity) { // When the bundle key is not on the 'base table', get it on the $entity // through entity_load(). if (!empty($entity_info['entity keys']['bundle']) && empty($entity->{$entity_info['entity keys']['bundle']})) { $loaded_entities = entity_load($target_type, array($entity->{$entity_info['entity keys']['id']})); if (empty($loaded_entities)) { continue; } $entity = reset($loaded_entities); } list($id,, $bundle) = entity_extract_ids($target_type, $entity); $return[$bundle][$id] = $result[$id]; }
To fix bug replace by code from v7.x-1.6
$target_type = $this->field['settings']['target_type']; $entities = entity_load($target_type, array_keys($result)); foreach($entities as $entity) { list($id,, $bundle) = entity_extract_ids($target_type, $entity); $return[$bundle][$id] = $result[$id]; }
- Status changed to Needs review
over 1 year ago 9:33pm 31 March 2023 - 🇭🇺Hungary danyg Budapest
Ok, here is an improved patch for this issue. It now respects if there is more than one bundle are being used in the reference field (like listing all pages and stories)
- 🇭🇺Hungary danyg Budapest
@psaleks Can you set the status to RTBC (Reviewed & tested by the community) if it looks good to you?
- 🇬🇧United Kingdom eckersley
I came here because I had the same problem. Patch #6 fixed it for me too. Thanks!
I tried the patch in #6 and got this error:
ParseError: syntax error, unexpected 'if' (T_IF) in _registry_check_code() (line 155 of [website]/sites/all/modules/entityreference/plugins/selection/EntityReference_SelectionHandler_Views.class.php).
- Status changed to RTBC
over 1 year ago 5:15am 5 April 2023 - 🇭🇺Hungary danyg Budapest
@SaIAG it's very strange, it looks that applying the patch wasn't successful for you and it caused a parse error.
The error comes from the same file but from an earlier point. Have you already applied a different patch on this module? - 🇨🇦Canada joseph.olstad
has anyone tested this patch with PHP 8.1 or PHP 8.2 ?
the count function is more strict since 8.1 and 8.2, just wondering if there's a scenario where
$return[$bundle]is not countable by PHP 8.1/ PHP 8.2 and the deprecated notice would show up?
@danyg #13 no, no other patches applied. I tried it once, it failed and I reverted to default module file.
Told the content guy to use intelli-sense on the name, which helps a little. Looking forward to the update.We're still on php 7.4.33. Don't know if that has anything to do with it.
- 🇨🇦Canada joseph.olstad
@SalAG, sounds like your patching tool might not be working correctly, could you please try modifying the module file manually and please test the changes with PHP 7.4 and then report the results to us?
-
joseph.olstad →
committed f73a617e on 7.x-1.x authored by
danyg →
Issue #3349989 by danyg, joseph.olstad, psaleks, LeDucDuBleuet,...
-
joseph.olstad →
committed f73a617e on 7.x-1.x authored by
danyg →
- Status changed to Fixed
over 1 year ago 4:34pm 14 April 2023 - Status changed to Fixed
over 1 year ago 4:44pm 28 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.