CommentFileSizeAuthor
#59 interdiff-2670954-58-59.txt309 bytesmrinalini9
#59 menu_link_uuid_nid-2670954-59.patch665 bytesmrinalini9
#58 menu_link_uuid_nid-2670954-58.patch665 bytesvbouchet
#56 menu_link_uuid_nid-2670954-56.patch619 bytesvbouchet
#52 menu_link_uuid_nid-2670954-52.patch610 bytesduaelfr
#52 interdiff.2670954.51.52.txt325 bytesduaelfr
#51 menu_link_uuid_nid-2670954-51.patch664 bytesduaelfr
#50 interdiff-43-50.txt709 bytesevilehk
#50 menu_link_uuid_nid-2670954-50.patch636 bytesevilehk
#49 interdiff-43-49.txt638 bytesevilehk
#49 menu_link_uuid_nid-2670954-49.patch636 bytesevilehk
#46 menu_link_uuid_nid-2670954-46.patch727 bytesvprocessor
#43 menu_link_uuid_nid-2670954-43.patch591 bytesandypost
#43 interdiff.txt251 bytesandypost
#41 menu_link_uuid_nid-2670954-41.patch591 bytesandypost
#41 interdiff.txt250 bytesandypost
#38 menu_link_uuid_nid-2670954-38.patch590 bytesandypost
#36 default_content-dependency_better_normalizers-2670954-27.patch282 bytesaaronbauman
#34 default_content-dependency_better_normalizers-2670954-33-TEST-ONLY.patch316 bytesaaronbauman
#32 default_content-dependency_better_normalizers-2670954-32-TEST-ONLY.patch302 bytesaaronbauman
#27 default_content-dependency_better_normalizers-2670954-27.patch282 bytesaaronbauman
#21 default_content-menu_link_normalizer-2670954-21-d8.patch2.96 KBSyndz
#19 default_content-menu_link_normalizer-2670954-19-d8.patch3.44 KBSyndz
#16 interdiff.txt934 bytesplopesc
#16 menu_link_uuid_nid-2670954-16.patch4.57 KBplopesc
#13 menu_link_uuid_nid-2670954-13.patch4.47 KBjibla
#12 menu_link_uuid_nid-2670954-12.patch4.5 KBjibla
#9 interdiff-2670954-5-7.txt5.17 KBjibla
#7 interdiff-2670954-5-7.patch5.17 KBjibla
#5 menu_link_uuid_nid-2670954-5.patch2.63 KBademarco
#5 interdiff.txt1.64 KBademarco
#3 interdiff.txt590 bytesademarco
#3 menu_link_uuid_nid-2670954-3.patch2.66 KBademarco
#2 2670954-2-menu-link-uuid-nid-normalizer.patch2.69 KBsanduhrs

Comments

sanduhrs created an issue. See original summary.

sanduhrs’s picture

Patch attached.

ademarco’s picture

Status: Active » Needs review
StatusFileSize
new2.66 KB
new590 bytes

URI seems to be exported as "entity:node/12345": I'm re-rolling the patch to take that into account in MenuLinkNormalizer::getNidFromUri().

Status: Needs review » Needs work

The last submitted patch, 3: menu_link_uuid_nid-2670954-3.patch, failed testing.

ademarco’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB
new2.63 KB

Re-rolling making sure tests pass.

larowlan’s picture

+++ b/src/MenuLinkNormalizer.php
@@ -0,0 +1,65 @@
+  function getNidFromUri($uri) {
+    preg_match_all('/entity:node\/(\d*)/', $uri, $matches);
...
+        $node_id = $this->getNidFromUri($link['uri']);
...
+          $target_entity = Node::load($node_id);
...
+        $node_id = $this->getNidFromUri($link['uri']);
...
+          $node = $this->entityManager->loadEntityByUuid('node', $link['_uuid']);
+          $data['link'][$key]['uri'] = str_replace($node_id, $node->id(), $link['uri']);

Can we make this entity-type agnostic. E.g. parse out the entity-type too, and inject the EntityTypeManager so we can use $this->entityTypeManager->getStorage($entity_type)->load($entity_id) instead of Node::load

Also, instead of using preg_match_all, we should use parse_url() like \Drupal\Core\Url::fromUri does.

Looking great though, nice work

jibla’s picture

StatusFileSize
new5.17 KB
  • Changed MenuLinkNormalizer in an entity-agnostic way.
  • Changed preg_match_all with parse_url()
  • Fixed coding standard issues.

Status: Needs review » Needs work

The last submitted patch, 7: interdiff-2670954-5-7.patch, failed testing.

jibla’s picture

StatusFileSize
new5.17 KB

Sorry, I had to upload .txt file.

jibla’s picture

Status: Needs work » Needs review
sanduhrs’s picture

@jibla Please provide a patch file with the full set of changes and if applicable an interdiff with only the differences to the previous patch.

jibla’s picture

StatusFileSize
new4.5 KB

Uploading full patch file.
/cc @sanduhrs

jibla’s picture

StatusFileSize
new4.47 KB

Changed method name, made it more clear and consistent with its purpose.

ademarco’s picture

Status: Needs review » Reviewed & tested by the community

Looking good! Marking as RTBC.

plopesc’s picture

Nevermind

plopesc’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.57 KB
new934 bytes

Working with this patch I had conflicts with Better Normalizers sandbox module, given that MenuLinkNormalizer class is not defining its specific $supportedInterfaceOrClass property.

Attaching a new patch that forces MenuLinkNormalizer to be used only for Drupal\menu_link_content\MenuLinkContentInterface objects.

Thanks

james.williams’s picture

When both my menu links and nodes are installed as default content from the same module, I hit this error:

Error: Call to a member function id() on null in Drupal\default_content\MenuLinkNormalizer->denormalize() (line 120 of /XXX/modules/contrib/default_content/src/MenuLinkNormalizer.php).

This is because the menu links don't declare their dependencies on the nodes, so are created before the nodes, so the denormalization introduced in these patches fails.

andypost’s picture

Status: Needs review » Needs work
  1. +++ b/default_content.services.yml
    @@ -2,3 +2,8 @@ services:
    +    arguments: ['@rest.link_manager', '@entity.manager', '@module_handler', '@entity_type.manager']
    

    entity.manager is not needed (deprecated)

  2. +++ b/src/MenuLinkNormalizer.php
    @@ -0,0 +1,128 @@
    + * @file
    + * Contains \Drupal\default_content\MenuLinkNormalizer.
    

    please remove

  3. +++ b/src/MenuLinkNormalizer.php
    @@ -0,0 +1,128 @@
    + * Class MenuLinkNormalizer.
    ...
    +class MenuLinkNormalizer extends ContentEntityNormalizer {
    

    Better brifly describe what if does and for

Syndz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.44 KB

I experienced the same problem as described in #17.

I decided to experiment a bit, here's a bit of a different take on the problem.

Status: Needs review » Needs work

The last submitted patch, 19: default_content-menu_link_normalizer-2670954-19-d8.patch, failed testing.

Syndz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB

Resolved a conflict with other normalizers with the same priority by stating a supported interface.

Status: Needs review » Needs work

The last submitted patch, 21: default_content-menu_link_normalizer-2670954-21-d8.patch, failed testing.

aaronbauman’s picture

Adding detail here per #2842533-2: Menu hierarchy not maintained after enabling menu link content

Latest patch doesn't fix the problem with menu hierarchy.
Menu item parents are still not assigned correctly when enabling default menu link content.

Latest patch *does* fix the problem with menu hierarchy, but requires all menu_link_content to be re-exported in order to build the dependencies.

larowlan’s picture

We should just make default_content depend on Better Normalizers and move http://cgit.drupalcode.org/entity_pilot/tree/src/Normalizer/MenuLinkCont... into it, and use it in both Entity Pilot and Default content.

aaronbauman’s picture

MenuLinkContentNormalizer has a chain of dependencies on entity_pilot, starting with UnsavedUuidResolverInterface and including entity_pilot/Exists plugin.

How do you suggest that this be untangled?

larowlan’s picture

Ah right, because Entity Pilot needs to dereference unsaved entities so it can preview incoming content.

We don't need that, but we need the other part of that logic to handle parent references.

aaronbauman’s picture

aaronbauman’s picture

Status: Needs work » Postponed
aaronbauman’s picture

Status: Postponed » Needs review

#2845455 is resolved - MenuLinkNormalizer is in better_normalizers now, so both this issue and #2845456 can proceed to review

Status: Needs review » Needs work
aaronbauman’s picture

results from testbot:

Unable to install modules: module 'default_content' is missing its dependency module better_normalizers.

uh... what?
this is a one-line patch to add a dependency.
is testbot broken?

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new302 bytes

TIL about "test_dependencies"

If this patch passes tests, then #27 should be considered for inclusion.

Status: Needs review » Needs work
aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new316 bytes

This should not be so difficult

Status: Needs review » Needs work
aaronbauman’s picture

OK, I give up.
I don't know how to add a dependency that will pass tests.

re-submitting #27

andypost’s picture

+++ b/default_content.info.yml
@@ -5,3 +5,4 @@ package: Web services
+  - better_normalizers

composer.json also needs update

andypost’s picture

StatusFileSize
new590 bytes

let's see what testbot will tell

andypost’s picture

Issue tags: +Needs tests

Adding a dependency on another module require test coverage

Status: Needs review » Needs work

The last submitted patch, 38: menu_link_uuid_nid-2670954-38.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new250 bytes
new591 bytes

Released new beta to allow composer to find dependency https://www.drupal.org/project/better_normalizers/releases/8.x-1.0-beta2

Status: Needs review » Needs work

The last submitted patch, 41: menu_link_uuid_nid-2670954-41.patch, failed testing.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new251 bytes
new591 bytes

One more round on composer dependencies

Status: Needs review » Needs work

The last submitted patch, 43: menu_link_uuid_nid-2670954-43.patch, failed testing.

andypost’s picture

Tests for 8.2 core passed, also commited #2849133: Add rest dependency

Keeping NW for tests

vprocessor’s picture

StatusFileSize
new727 bytes

patch rerolled

andypost’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 46: menu_link_uuid_nid-2670954-46.patch, failed testing.

evilehk’s picture

Status: Needs work » Needs review
StatusFileSize
new636 bytes
new638 bytes

I wasn't able to get patch #46 to apply to the commit before "20 May 2017 at 12:15". I was able to apply patch #43 to the commit before "11 February 2017 at 05:05", and then rebased and resolved conflicts. Attached is a rerolled patch of 43 with an interdiff.

evilehk’s picture

StatusFileSize
new636 bytes
new709 bytes

Missed a commit. Take 2.

duaelfr’s picture

StatusFileSize
new664 bytes

Rerolled on last dev version

duaelfr’s picture

StatusFileSize
new325 bytes
new610 bytes

This patch:
- removes an uneeded dependency on the rest module introduced by #49
- removes the test_dependency addition to the info file as the documentation indicates it's only useful if it is different from dependencies

duaelfr’s picture

This issue is super useful to deal with menus.
It'd be really cool if people that use these patches could jump in and say "hi" :)

vijaycs85’s picture

+1 to have better_normalizers here.

vijaycs85’s picture

Title: Menu link UUID NID normalizer » Add Better Normalizers as a dependency
Category: Bug report » Feature request
vbouchet’s picture

StatusFileSize
new619 bytes

I tested it and it works very well.

Please find an updated version of DuaelFr's patch.

vbouchet’s picture

Ok, I just edited DualFr test without properly testing it and I missed to update the drupal/core version in composer.json. Also the info.yml does not contain the core attribute anymore, only core_version_requirement. Please find an updated patch.
It sill fails on my local due https://www.drupal.org/project/drupalorg/issues/3066468

vbouchet’s picture

StatusFileSize
new665 bytes
mrinalini9’s picture

StatusFileSize
new665 bytes
new309 bytes

Fixed require failure issue in #58, please review.

vbouchet’s picture

Status: Needs review » Reviewed & tested by the community

Thanks mrinalini9. It works well.

berdir’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

I've recently created the 2.0.x branch, see the project page on all the improvements in the 2.0.x branch. Testing that and providing feedback would be very welcome. The 1.x branch isn't actively maintained and won't receive new features anymore, so I'm closing this and other issues as won't fix.

2.0.x uses a completely different normalization implementation that does not depend on hal.module anymore and all the features of the better normalizers module are built-in.