Problem/Motivation

When exporting menu_link_content entities and child menu_link_content is exported with dependencies, it doesn't export parent menu_link_content entity attached to it.

Steps to reproduce

  1. Create a parent menu link content entity in menu "main".
  2. Create a child menu link content entity with the parent reference.
  3. Run export command to export child menu link content entity. Ex:
    $ php core/scripts/drupal content:export menu_link_content <child_menu_link_content_id> --with-dependencies --dir=public://content
    
  4. The parent menu link content should be exported as well.

Proposed resolution

Create a DefaultContentEventSubscriber in menu_link_content module.

Issue fork drupal-3562072

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vishalkhode created an issue. See original summary.

vishalkhode’s picture

Status: Active » Needs review
phenaproxima’s picture

Status: Needs review » Needs work

I think this is a great find, and a great fix with very strong test coverage. There are a few things I think we should do differently, but they are implementation details. Solid stuff!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

phenaproxima’s picture

Status: Needs work » Needs review

Addressed my feedback and converted the test to a kernel test, which is quite a bit easier to introspect.

phenaproxima’s picture

godotislate’s picture

A couple of nit-ish comments on the MR, but I'm OK for RTBC.

phenaproxima’s picture

Thanks, @godotislate! Accepted your suggestion on the MR.

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

alexpott made their first commit to this issue’s fork.

godotislate’s picture

There've been changes since it was moved into RTBC, so just in case, I've looked again and it's still good.

alexpott’s picture

Version: main » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 54bc9308376 to main and e065ffa1d4a to 11.x and c9562cad300 to 11.3.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed c9562cad on 11.3.x
    fix: #3562072 Menu link content export with dependencies doesn't include...

  • alexpott committed e065ffa1 on 11.x
    fix: #3562072 Menu link content export with dependencies doesn't include...

  • alexpott committed 54bc9308 on main
    fix: #3562072 Menu link content export with dependencies doesn't include...

Status: Fixed » Closed (fixed)

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