alkacon / opencms-core

The Java open source content management system by Alkacon Software
http://www.opencms.org
GNU Lesser General Public License v2.1
525 stars 576 forks source link

Bug with relations for siblings in online project not updated (2) #806

Open tobias-karrer opened 6 days ago

tobias-karrer commented 6 days ago

I did a cherry pick and patched the classes from commit https://github.com/alkacon/opencms-core/commit/76c7006930e8037012544324dde292af4ec3ee7e accordingly in OpenCms 14, but looks like the problem still exists. And depending how editors use the publish dialog might be even more confusing now.

Steps to reproduce:

I add a content to /de/investoren/index.html image

And then publish this page with its content resource: image image

The sibling /en/investors/index.html still be published anyway and is not in publish list (even if "Publish silbings" is unchecked - see my comment here https://github.com/alkacon/opencms-core/issues/802#issuecomment-2388873853)

And it /en/investors/index.html does not exist in relations: image

The fix for https://github.com/alkacon/opencms-core/issues/805 now sets state of /en/investors/index.html to "changed", but it already was published before - see version 13 in history here: image

So /en/investors/index.html was published (version 13), but now still has state "changed" (Offline version). Editors might get confused as there are no changes to be published: image

I'd guess the fixes are not applied for demo server yet to check the behaviour there?

Or is there something else that changed regarding siblings from OpenCms 14 to 17? So the applied patches won't work for version 14?

BR, Tobias

gWestenberger commented 5 days ago

I don't know specifically about OpenCms 14, but this is the intended behavior. The problem was that originally /en/investors/index.html showed up as published after modifying and publishing the German sibling. But it was not actually published. It had in fact unpublished changes: The relations from /en/investors/index.html to the new content elements. The change makes this fact visible. You have to publish the English sibling.

tobias-karrer commented 5 days ago

But it was not actually published. It had in fact unpublished changes

Hmm, no. That's the issue (as mentioned in https://github.com/alkacon/opencms-core/issues/802 as well). The English sibling already is published (!) automatically by OpenCms when publishing the German sibling (without checking "Include siblings") But it the published English sibling doesn't show in publish list, nor are the relations for English sibling to content elments updated in database.

After the fix, if "Include siblings" is not checked, OpenCms now does

gWestenberger commented 5 days ago

No. It is not already published automatically. That's the whole problem (and why the relations are missing in the Online project).

The resource state you can see in the explorer (or get from a CmsResource object) is actually a mixture of two states: The structure state (CMS_OFFLINE_STRUCTURE.STRUCTURE_STATE) and the corresponding resource state (CMS_OFFLINE_RESOURCES.RESOURCE_STATE). For a given set of siblings, there is only one entry in CMS_OFFLINE_RESOURCES, but multiple CMS_OFFLINE_STRUCTURE entries for all its siblings in the file system. What you get when you read a resource is basically a combination of the data from CMS_OFFLINE_RESOURCES and CMS_OFFLINE_STRUCTURE, joined via RESOURCE_ID.

Previously, when writing an XML content, only the RESOURCE_STATE got updated. This caused all the siblings to show up as red. But the relations corresponding to the links contained in it got updated on all the siblings, without updating the STRUCTURE_STATE. So the STRUCTURE_STATE remained "unchanged" for all siblings.

If you now published one of the siblings and not the others, it would transfer its data from the Offline project to the Online project, and set the RESOURCE_STATE back to unchanged. This would cause the other siblings to show up as black in the Explorer, despite the fact that they had never gone through the publish process, and thus their relations had never been published.

The fix makes it so the STRUCTURE_STATE gets set to "changed" as well. So publishing just one sibling means the others will still show up as red in the Explorer, and can be published separately.

tobias-karrer commented 5 days ago

Hmm, ok, thanks for the detailled explanation. So if I got it correctly, the second sibling (the one not published) gets it's state changed but was never published. And changes in the XML content would be be visible on the not published resource in Online project as well, as the content resource itself was published.

But when it is not published, why there's a publish entry with publish date in history? image

That's confusing then.