menu_node_submit() calls entity_create() when $form_state['values']['menu'] is empty which results in the following message appearing:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Entity\Entity->__construct() (line 72 of core/lib/Drupal/Core/Entity/Entity.php).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benjy’s picture

Can you provide the steps to reproduce against the latest head. I'm unable to replicate by adding menu links, or content with menu entries.

idflood’s picture

I've found the same issue. Here are the steps to reproduce:

  1. Create a new content type (or edit an existing one).
  2. In the "Menu settings" tab uncheck all "Available menus".
  3. Create a new content.

edit: here is some relevant lines of the backtrace

Drupal\Core\Entity\Entity->__construct(NULL, 'menu_link')
Drupal\Core\Entity\DatabaseStorageController->create(NULL)
Drupal\menu_link\MenuLinkStorageController->create(NULL)
entity_create('menu_link', NULL)
menu_node_submit(Object, Array, Array)
Drupal\node\NodeFormController->submit(Array, Array)
call_user_func_array(Array, Array)
form_execute_handlers('submit', Array, Array)
drupal_process_form('note_node_form', Array, Array)
drupal_build_form('note_node_form', Array)
Drupal\Core\Entity\EntityManager->getForm(Object)
node_add(Object)
call_user_func_array('node_add', Array)
...
idflood’s picture

Issue summary: View changes

Added code tags

alphawebgroup’s picture

Assigned: Unassigned » alphawebgroup
Issue summary: View changes
FileSize
1.19 KB
alphawebgroup’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: 1986000-3.patch, failed testing.

alphawebgroup’s picture

Status: Needs work » Needs review

3: 1986000-3.patch queued for re-testing.

Blooniverse’s picture

Status: Needs review » Reviewed & tested by the community

#3: 1986000-3.patch works, for me. Thanks for the work!
Changing status to RTBC.

xjm’s picture

3: 1986000-3.patch queued for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Nice catch! Let's get an automated test added for this.

Berdir’s picture

Assigned: alphawebgroup » Unassigned
Priority: Normal » Minor
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
3.31 KB
2.12 KB

This is now a recoverable fatal error that prevents creating nodes with that configuration, so raising to major.

Attached patch adds tests and as a bonus, converts MenuNodeTest to not use the standard profile which means that the test is now ~3 times faster :)

Berdir’s picture

Priority: Minor » Major

Uhm. The other major ;)

Dragan Eror’s picture

Status: Needs review » Reviewed & tested by the community

Tested patch from #10, works nice.

  1. Created content of content type Article, saved, edited, saved.
  2. Changed content type Article settings, removed all available menus.
  3. Edited same Article content again, saved. It works! :)

Thanks Berdir

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: missing-menu-fatal-error-1986000-10-test-only.patch, failed testing.

Berdir’s picture

Status: Needs work » Reviewed & tested by the community

Had the test only patch in the wrong order, this passed/failed as expected.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Berdir’s picture

Title: Warning when adding content with an empty menu path » HEAD BROKEN: Warning when adding content with an empty menu path
Priority: Major » Critical
Status: Fixed » Needs review
FileSize
563 bytes

Ok, bad timing, this conflicted with https://drupal.org/node/1541298 and needs an exlicit dependency on node now.

alexpott’s picture

Title: HEAD BROKEN: Warning when adding content with an empty menu path » Warning when adding content with an empty menu path
Priority: Critical » Major
Status: Needs review » Fixed

Committed 21fca46 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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