If the parent content type in an Entity Reference Hierarchy relationship also has a field with 'Require on Publish' set to true, going to that node's 'Children' pane causes the following error:

TypeError: Argument 1 passed to require_on_publish_add_indicator() must be of the type array, null given, called in /Users/aoneill/Sites/d8/web/modules/contrib/require_on_publish/require_on_publish.module on line 178

The problem is in 'require_on_publish_form_alter', where it assumes the form object contains the field, even though the 'Children' page is not the same as the entity edit form.

Attaching a patch.

Comments

alxp created an issue. See original summary.

alxp’s picture

Issue summary: View changes
alxp’s picture

Patch that does a simple check before accessing a field value in hook_form_alter().

alxp’s picture

Status: Active » Needs review
alxp’s picture

To reproduce:

Enable Require on Publish and Entity Reference Hierarchy (https://www.drupal.org/project/entity_hierarchy)

On Standard Drupal install, go to Admin -> Structure -> Content Types.

Edit Fields of Basic Page, add a new field and mark it as 'Require on Publish.'

Edit fields of Article, add a Entity Reference Hierarchy field and make it point to the Basic Page bundle.

Clear Drupal cache.

Add content items of each type, and select the basic page content item in the Entity Reference Hierarchy field of the article content item.

Go to the Basic Page content item you created, and click on the Children tab.

mpriscella’s picture

Looks good, thanks! I'll merge it in tonight and create a new release.

  • mpriscella committed cabd1c2 on 8.x-1.x authored by alxp
    Issue #3021630 by alxp: Not compatible with Entity Reference Hierarchy
    
mpriscella’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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