Tiny bug that can cause notices: $info is not initialized in redirect_field_extra_fields and can result in an attempt to return an uninitialized variable if no entitites supporting redirects are found. We're seeing this notice during simpletest-runs.

The code in question

function redirect_field_extra_fields() {
  $entity_info = entity_get_info();
  $info = array();
  foreach (array_keys($entity_info) as $entity_type) {
    if (!redirect_entity_type_supports_redirects($entity_type)) {
      // Redirect is explicitly disabled for this entity type.
      continue;
    }
    foreach (array_keys($entity_info[$entity_type]['bundles']) as $bundle) {
      if (!isset($entity_info[$entity_type]['bundles'][$bundle]['uri callback']) && !isset($entity_info[$entity_type]['uri callback'])) {
        // The bundle or base entity must have an URI callback defined otherwise
        // we cannot use the entity_uri() function to lookup the entity's source
        // path.
        continue;
      }
      $info[$entity_type][$bundle]['form']['redirect'] = array(
        'label' => t('URL redirects'),
        'description' => t('Redirect module form elements'),
        'weight' => 30,
      );
    }
  }
  return $info;
}

Comments

danquah created an issue. See original summary.

danquah’s picture

Title: Notice in redirect_field_extra_fields » Notice in redirect_field_extra_fields due to missing initialization
Status: Active » Needs review
StatusFileSize
new515 bytes
chris matthews’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #2 is 3 years old, but it still applied cleanly to the latest 7.x-1.x-dev and is a small but reasonable fix to me so changing the status to RTBC.

pifagor’s picture

  • pifagor committed 35cce80 on 7.x-1.x authored by danquah
    Issue #2562079 by danquah, Chris2, pifagor: Notice in...

  • pifagor committed 29ff4ae on 7.x-2.x
    Issue #2562079 by danquah, Chris2, pifagor: Notice in...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed
alex_optim’s picture

Good for me.

pifagor’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.