The two entity view functions in fieldable_panels_panes.module have different arguments: in one the $langcode defaults to NULL, and in the other it doesn't. The code comments imply that they are supposed to be duplicates.


/**
 * View a fieldable panel pane.
 *
 * @see node_view()
 */
function fieldable_panels_panes_view($entity, $view_mode = 'full', $langcode = NULL) {
  return entity_get_controller('fieldable_panels_pane')->view($entity, $view_mode, $langcode);
}

/**
 * Entity API callback to view a fieldable panel pane.
 *
 * This is essentially a duplicate of fieldable_panels_panes_view() but the
 * function name has to match the entity type with is singular.
 *
 * @see entity_view()
 */
function fieldable_panels_pane_view($entity, $view_mode = 'full', $langcode) {
  return entity_get_controller('fieldable_panels_pane')->view($entity, $view_mode, $langcode);
}

It seems like the langcode should be defaulted to NULL in both cases. If it isn't, and if code calling the 2nd function omits the langcode, it's going to start throwing an ArgumentCountError as of PHP 7.1.

Comments

cboyden created an issue. See original summary.

cboyden’s picture

Assigned: cboyden » Unassigned
Status: Active » Needs review
StatusFileSize
new580 bytes

See attached patch, which makes the 2nd version of the function default the langcode to NULL.

damienmckenna’s picture

That makes complete sense, thank you.

Lets make the code even more clear.

  • DamienMcKenna committed 2633013 on 7.x-1.x authored by cboyden
    Issue #2936307 by DamienMcKenna, cboyden: View functions handle langcode...
damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

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

liam morland’s picture

Issue tags: -php7.1 +PHP 7.1