Problem/Motivation

When importing content that has cross-links such as multiple nodes that link to each other using the data-entity replacements, single_content_sync currently loads the entity by UUID and replaces the href of the element to update the possible change in Node Id , however when it encounters a link such as /node/123#something it would simply replace it with the canonical link to the new node id ex: /node/321 without the #something.

Steps to reproduce

- Create a few pages,
- Add links between each pages to each other to specific anchors within the page.
- Export / Import those pages on a new environment or site.
- Observe that the Node links are all updated to their new Id's however any links to specific anchors are lost.

Proposed resolution

Alter the import process in the src/Plugin/SingleContentSyncFieldProcessor/TextField.php importFieldValue function so that it parses the original URL to retain the fragments and query IF the entity needs_udpate is TRUE so that the replaced url preserves the url query and fragments.

I've included an initial patch which seems to correct the issue on my use case. I don't know if the same functionality / import is used elsewhere in the module but if pointed in the right direction I'd happily volunteer some time to update the patch to match the process accross the various imports.

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

theduke13 created an issue. See original summary.

theduke13’s picture

theduke13’s picture

Status: Active » Needs review
theduke13’s picture

Version: 1.4.13 » 1.4.14
Category: Feature request » Bug report

I've opened an issue fork and committed the fix to the latest version. I've hidden the patch for clarity sake.