Comments

jeqq created an issue. See original summary.

bahbka’s picture

Steps to reproduce:
1. Push one node or any other entity(that have aliases) from one workspace to another.
2. Disable multiversion support for that entity type.

Expected result: all data related to none default workspace will be deleted.
Actual result:
1. Node/Entity that belonged to default workspace was deleted and none default workspace entity is left and accessible.
2. Aliases records got duplicated.

railgun’s picture

Status: Active » Needs review
StatusFileSize
new5.05 KB

We assume that the issue described by @BAHbKA can be fixed by deleting all the entities that belong to non-default workspaces before doing the migration. @jeqq please review the patch I have attached.

jeqq’s picture

Status: Needs review » Needs work
StatusFileSize
new220.85 KB
new106.37 KB
new159.35 KB

@railgun Thanks for the patch! I think we should use another approach when fixing this.

We shouldn't delete any entities from non-default workspace because of that is taking care the Workspace module, when that module is uninstalled, it deletes all non-default workspaces and entities associated with them. After that the url_alias table contains only aliases for entities on the default workspace.

We should fix this:
1. Make alias field unique, after uninstalling multiversion
2. Fix migration of the url aliases when entities are migrated back from the temporary storage on Multiversion uninstall. There is probably a way to not duplicate aliases, but replace or leave there those that already exist. If we make the alias filed unique it won't allow at all duplicate aliases and there will be an error when saving any duplicates - that is how it should work when Multiversion is not installed.

Explanation for 2.: when uninstalling Multiversion, it duplicates node url aliases because on migration it doesn't take into consideration already existing aliases into the database.

Steps to reproduce:

  1. drush si -y
  2. drush en deploy -y
  3. Create 2 nodes with aliases on Live workspace, replicated them to Stage. Create a new workspace (Test), replicate all nodes from Stage to Test. At this point you'll see 4 entries in url_alias table.
  4. drush pmu deploy -y
  5. drush wun -y
  6. drush repun -y
  7. At this point in the url_alias table should be 2 entries - for the nodes from live, that's correct
  8. drush mun -y
  9. MUltiversion successfully uninstalled, but in the url_alias table are 4 entries, when the 2 nodes have been migrated back from temporary storage, they created new aliases in the database.

After deploying the 2 nodes to Stage and Test:
zzz

After uninstalling Workspace and before uninstalling Multiversion:
zzz

After uninstalling Multiversion:
zzz

bahbka’s picture

Hi @jeqq, thank you for the review!
Here is scenario that we used to replicate #comment-13081172 issue:

  1. drush si -y
  2. drush en deploy -y
  3. Create 1 node with title 'Default workspace' on Live workspace, replicated them to Stage.
  4. Make edits to this node in the Stage workspace -> change it title to 'Stage workspace'
  5. drush mdt node -y

As a result:

  • Node with the title 'Default workspace' will be deleted
  • Node with the title 'Stage workspace' will be accessible for the anonymous users
  • Two url aliases 'default-workspace' & 'stage-workspace' will be present in the url_aliases table

I believe that same issues will happen when you will run 'drush mun -y' as the first step will be to disable multiversion support and then delete workspace entities.

jeqq’s picture

@BAHbKA I see, when using drush mdt node -y command and Workspace module is not uninstalled then we can have multiple workspaces.

Truncating entity tables was an improvement and I don't like the idea of deleting again every entity from the non-default workspaces (as we try to do in #3)- this is a performance downgrade, if we do this, then our fix from #3048954: An alternative approach to including/excluding content types into "multi-versioning". was work in vain.

A solution would be on uninstall (after migrating entities to temporary storage and before migrating them back) to just loop through the url_alas table values and delete from there all the entries where we have as source /node/NODE_ID (maybe we have other possible cases?).

bahbka’s picture

StatusFileSize
new20.69 KB

@jeqq I see that my steps is a bit misleading e.g. disable node type with workspaces being enabled - doesn't make any sense. So I did the same as you in #4:
- drush si -y
- Created 2 nodes pushed them and edit them in different workspaced
- drush pmu deploy -y
- drush wun -y
- drush repun -y
- commented drush_module_uninstall(['multiversion']); in the drush command
- drush mun -y

After these steps I can see that:
- Proper version of a node is kept & displayed
- All none default workspace entities are deleted - as it should be
- And URL alias table is showing:
duplicated alias

My proposed solution is to delete all records form url alias table with workspace == 0 right before dropping workspace column from this table e.g. multiversion_uninstall . @jeqq what do you think about this?

P.S. the only unique key in url_alias table is pid, so you can add as many aliases for the one source as you want using SQL queries.

bahbka’s picture

Attaching patch and interdiff for the proposed solution.

bahbka’s picture

Status: Needs work » Needs review
jeqq’s picture

@BAHbKA You are right regarding, alias field not being unique, I got confused because I remembered that on node saving duplicate alias is not allowed, but that is restricted by the storage class, not database, sorry.

Will test the new solution I think it should work.

jeqq’s picture

Status: Needs review » Needs work

@BAHbKA Yes, that works, but I think it's still not the best solution. That because it creates unnecessary entries in the database, then we delete them. The best solution would be to control that on entity migration to multiversion/drupal storage, somewhere in a new process or destination plugin (Drupal\multiversion\Plugin\migrate\destination\EntityContentBase). On entity migration from the temporary storage it should do a check, if there exists already that alias, it shouldn't save a new one.

What do you think?

bahbka’s picture

Status: Needs work » Needs review
StatusFileSize
new919 bytes
new563 bytes

Hi @jeqq attaching new patch

jeqq’s picture

Title: Followup: Fix the url_alias table after un installing multiversion and make sure aliases are migrated correctly » Followup: Fix url alias migration on module install and uninstall
Issue summary: View changes

Thanks @BAHbKA! Will review it tomorrow morning.

jeqq’s picture

Status: Needs review » Needs work

@BAHbKA This works perfectly when uninstalling the module, but when installing the module it still deletes existing aliases and creates new ones (with new PIDs). Could we keep path aliases on module install and avoid deleting them and creating again (as we do on uninstall)?

bahbka’s picture

@jeqq Unfortunately with a current approach when we are installing a module it triggers entity delete method that's deleting everything connected to the entity e.g. no calls to the truncate function. Thats why pids are changed and this fix for the url aliases applied only when multiversion module gets disabled.

jeqq’s picture

Status: Needs work » Reviewed & tested by the community

@BAHbKA Fair enough, thanks! I'll commit this.

  • jeqq committed 8fd29f7 on 8.x-1.x authored by BAHbKA
    Issue #3050398 by BAHbKA, railgun: Followup: Fix url alias migration on...
jeqq’s picture

Status: Reviewed & tested by the community » Fixed
gaydamaka’s picture

Status: Fixed » Needs review
StatusFileSize
new355.36 KB
new3.22 KB

We get a duplicate alias on migration if we have the "Pathauto" module on the site.
Pathauto
And we need to skip saving a new alias on migration.

spheresh’s picture

Looks good for me. It seems that patch #12 can be reverted if these changes are received.

jeqq’s picture

Status: Needs review » Fixed

Thank you for the patch!

This patch should leave in another issue, not here, this is already fixed and the change is already in the latest module release. Please create a new issue, with a proper description and upload the patch there. This issue fixed the problem without Pathauto module installed. Thanks!

Status: Fixed » Closed (fixed)

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