PHP 8.1 Compatibility issue

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rudraksh_98 created an issue. See original summary.

rudraksh_98’s picture

fixing issue for PHP 8.1 Compatibility

rudraksh_98’s picture

Status: Active » Needs review
marrrc’s picture

fixed relative paths for patched file

anybody’s picture

Thanks @marrrc - could you perhaps provide this as Merge Request? (MR)

grevil’s picture

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.

anybody’s picture

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?

grevil’s picture

Status: Needs review » Closed (outdated)

@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;
}