The left-associativity of the ternary operator has been deprecated in PHP 7.4 and removed in PHP 8.0

Created on 10 August 2022, over 2 years ago
Updated 23 January 2023, about 2 years ago

PHP 8.1 Compatibility issue

🐛 Bug report
Status

Closed: outdated

Version

1.6

Component

Code

Created by

🇮🇳India rudraksh_98

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪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
  • 🇩🇪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;
    }
    
Production build 0.71.5 2024