The argument description for views_handler_field::add_additional_fields() states that:

The key is an identifier used to later find the field alias used.

This is only true if the passed $info is an array. When $info is a string, the field name is used instead.

Example for correct behavior:

    $this->add_additional_fields(array(
      'langcode' => array('field' => 'language'),
    ));

$this->aliases now contains a key "langcode" with the field alias.

Example for wrong behavior:

    $this->add_additional_fields(array(
      'langcode' => 'language',
    ));

$this->aliases now contains a key "language" with the field alias.

Comments

ciss created an issue. See original summary.

ciss’s picture

Title: add_additional_fields() ignores identifier if value is a string » add_additional_fields() ignores identifier if $info is a string
Issue summary: View changes
ciss’s picture

It looks like the same bug made it into Drupal 8: https://github.com/drupal/drupal/blob/dba4fcf36a0963831e775e71ac8626425e...