sulu / SuluArticleBundle

Bundle for managing localized content-rich entities like blog-posts in the Sulu content management system
MIT License
57 stars 78 forks source link

Fix PhpCR migration exception for unpublished languages #698

Closed Cephra closed 2 months ago

Cephra commented 2 months ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
License MIT

What's in this PR?

This PR checks if the nodes have properties during the migration

Why?

Without this, articles which haven't been published cause migrations to fail.

Prokyonn commented 2 months ago

@Cephra Thank you for the merge request. The check for property existence does make sense, but I’m not entirely sure it applies to unpublished articles.

If an article is only saved as a draft and not published it should not be selected because it does not have a mixinType so the condition ([jcr:mixinTypes] = "sulu:article" OR [jcr:mixinTypes] = "sulu:articlepage") should be false. After it was published once, the template property must be set.

So I cannot really reproduce your issue 🤔

alexander-schranz commented 2 months ago

@Cephra can you show us how such article looks like in your phpcr storage? How can such articles be created?

Prokyonn commented 2 months ago

I was able to reproduce the issue. It occurs when you have multiple locales (e.g., de and en) and only publish the article in de. In this case, the unlocalized mixin:type property is set correctly, but for en, the templateKey is missing, causing the migration to crash.

Thanks to @Cephra for identifying and fixing this issue in a merge request!

Cephra commented 2 months ago

Hello @Prokyonn & @alexander-schranz,

firstly thanks for accepting and merging the fix.

I also want to thank @FlorianKoerner who has helped me find and fix this bug!