- 🇩🇪Germany Grevil
if (!$form_build_id = (isset($_GET['form_build_id']) ? $_GET['form_build_id'] : isset($_POST['form_build_id'])) ? $_POST['form_build_id'] : NULL)
Doesn't really make sense to me, I think it should be:
if (!$form_build_id = isset($_GET['form_build_id']) ? $_GET['form_build_id'] : (isset($_POST['form_build_id']) ? $_POST['form_build_id'] : NULL))
Instead.
- 🇩🇪Germany Anybody Porta Westfalica
Starting with a negated assignment (
!$form_build_id =
) in an if clause isn't a good idea at all. It makes things hard to read and understand and is thereby prone to mistakes.So could we please unclutter this?
- Status changed to Closed: outdated
about 2 years ago 9:03am 23 January 2023 - 🇩🇪Germany Grevil
@Anybody, actually there is no need to do anything here, as it got already resolved. This is the current implementation of the function:
function entityreference_prepopulate_get_values_from_cache($field, $instance) { // Try to get the form out of cache. if (isset($_GET['form_build_id'])) { $form_build_id = check_plain($_GET['form_build_id']); } elseif (isset($_POST['form_build_id'])) { $form_build_id = check_plain($_POST['form_build_id']); } else { return; } $field_name = $field['field_name']; $form_state = array(); form_get_cache($form_build_id, $form_state); // If successful, get the value from the form_state. return isset($form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field_name]) ? $form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field_name] : FALSE; }