New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-25377 fix republish modifying publication date #1557
EZP-25377 fix republish modifying publication date #1557
Conversation
64eac2a
to
abff4ea
Compare
$content = $this->internalPublishVersion($content->getVersionInfo()); | ||
$content = $this->internalPublishVersion( | ||
$versionInfo, | ||
$versionInfo->contentInfo->published ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would probably move this above for better readability, i mean, the ternary operation
beside my comment, looks good to me. let's see what travis says :) |
+1 There was someone reporting that the logic on modification data is a bit wrong, I think the outcome of the discussion was that perhaps modified date should be set to the modified date of the versionInfo. However that discussion might have been brought up because of this issue with publication date which was confusing reporter in regards to what should be expected. Thoughts? |
Maybe... do you have a link to the report? |
@andrerom Now that you mention it, I think you're right. it is only logical that modification date be set to modification date of the version which is about to be published. |
But you need to set it to the content too, right? |
We're talking about content, yes :) So instead of setting the modification date to |
But isn't the modification date of the version |
Is it? What happens if the draft is published a day or two after is was last modified? |
When you publish it, isn't the modification of the version also changed? Isn't |
That's the question. Is that the expected behaviour? Or in other words, does publishing a version constitute as modification of the version? It needs to be verified in legacy. I'm more inclined to believe that the behaviour over there is correct (in case it differs from behaviour here) :) But still, in theory calling |
I vote for yes. The status of the version is modified. |
@emodric I am not 100% sure that legacy behaviour is either consistent or logical. It was never documented anywhere, and you can see that different devs had different ideas about those dates by the simple fact that the naming in code and in the gui suggest different things... @bdunogier I do not agree necessarily that the act of publication should change the modification-date of a version. So if we have a draft version which we edited yesterday, and today we publish it unchanged, it would make sense to me that the object modification date is different from the version modification date. As long as we do not have version modification dates for non-drafts which are later than object modification dates, everything should still make sense. |
Last but not least: @bdunogier we currently have no date which tracks any other objects events apart from modification of attributes (version publication): hide/show, set-state, set-section are, between others, all events which do not alter the object modification-date. |
@emodric: question could also be "should we consider that content has been modified y that version is in draft?" I'd say no if i thinking in with the final user will see. I mean, if that version is in draft, what visitors of the site will see is the last published version of the content... In other words, suppose we have a blog post dated on 2016-01-14. This date is showed as last modified date to the vistitors. Editor creates a draft tomorrow. That draft is either never published or never approved... Should we tell the visitor of the site that last modification of what's beein seing is 2016-01-15 or whatever? I would say that shouldn't change until that new version gets published... |
Hi all, interesting discussion here.. I am not sure how the legacy works, nor how it was originally imagined, but for what it's worth, I am inclined to agree with @gggeek's description. If the version (draft) has been created/modified the day before it was actually published, I, as developer, would expect the content's modified date to be the one when it was published. And then, if needed, I can dig into the version info to find when was the version created and last modified. |
Maybe, but we should at least make it consistent, both in eZ kernel and legacy. My view of all four timestamps: object creation date = moment of publication of v1 |
i'm doing some test with legacy backend.
(note spanish date format here) Editing that content and saving draft. then
Publishing version 2
So, it looks when you publish the version, the version modification date is also changed and that value is also used to set the new object modification date... This is how it works now, but yep, interesting discussion :) |
@emodric and mine too :) |
there's another edge case with version modification date... don't remember how it works when you have ezautosave in place... |
Hm... Never used it myself, it was always one of the first things I disabled when installing eZ :) But should it be considered at all, since it doesn't exist in the new stack? |
it doesn't, but maybe it will :) |
side note... and if i'm not wrong, content versioning will change a bit in new stack, won't it? i mean, i remember something about you will can create different views of the same content depending on browser settings like language, ip of the visitor... etc... site note 2: actually there's also something to be considered with translation. actually when you add a french translation to a content with main language being english, content modification date gets changed too... but user visiting english version of the site won't see any change... right? |
@emodric I am not sure I agree with the fact that object modification date should be aligned with the date of last modification of version fields. Just consider that 99% of ez websites have some approval / delayed publication workflows. In both cases, what the end user has to see is the date of content/new version appearing on the site, not the date when fields were modified. |
exactly my point @gggeek :) |
@gggeek Hm... Okay. Maybe you're right. But I still think that modification date of an object should be the same as modification date of the last published version, that is, publishing the version should update its modification date. |
@andrerom if i'm not wrong, what happens before this patch is creation date is also updated when you modify the object (publish new version). |
@crevillo what do you mean by creation date? As far as I remember metadataUpdateStruct acts on the Content where there is no such thing, and does not act on the Version. |
@andrerom With @iherak's patch applied, after publishing the content and going to details tab i can see
i guess those are content (contentInfo) creation and modification dates, aren't they? Without the patch, i republish this content and i have...
So, looks like last modification and creation date are the same. |
On content, it's called "publishedDate", but yes, it should show the time of the first publishing. That's how it behaves in legacy AFAIK, does it not? |
and btw, if you look the database without @iherak patch, now i can see published date has been modified.
|
@crevillo there is no concept of created date for content object in kernel, what labels they use in ui and if that is misleading is a bug there. |
@andrerom no published date either? Edit: Leaving this platformui question for @dpobel or maybe @rolandbenedetti, i ask. is ok that |
To add to what @crevillo asked, if that is so, does that mean that there is no proper way of having the date of the first publish? |
Object published date has always been the timestamp of first publish. Once the object was created, it was never modifed again. Object modified date has always been the timestamp of last publish. |
according to what @emodric says (and I second) we should
|
@@ -1456,7 +1461,7 @@ protected function internalPublishVersion(APIVersionInfo $versionInfo, $publicat | |||
|
|||
$metadataUpdateStruct = new SPIMetadataUpdateStruct(); | |||
$metadataUpdateStruct->publicationDate = isset($publicationDate) ? $publicationDate : time(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather remove the changes in publishVersion
and do something like this on this line to make sure all use of this have the same behaviour everywhere, and be closer to how legacy behaves:
if ($publicationDate === null && $versionInfo->getContentInfo()->publishedDate->getTimestamp() === 0) {
$publicationDate = time();
}
$metadataUpdateStruct = new SPIMetadataUpdateStruct();
$metadataUpdateStruct->publicationDate = $publicationDate;
php doc something like:
@param int|null $publicationDate If null existing date is kept if there is one, otherwise current time is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrerom It should probably be:
if ($publicationDate === null) {
$publicationDate = $versionInfo->getContentInfo()->publishedDate->getTimestamp() ?: time();
}
Right?
EDIT: Disregard. My snippet is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is allowed to be null, ref the meta update struct php doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrerom would something like this work:
if ($publicationDate === null && $versionInfo->getContentInfo()->publishedDate === null) {
$publicationDate = time();
}
From what I gather, the published date is never set to timestamp 0, but to null (when I tried your snippet, got exception, so I tried to dig around a bit).
Alternatively, we could be a bit more explicit (while preserving the desired behaviour), and do something like this:
if ($publicationDate === null && $versionInfo->versionNo === 1) {
$publicationDate = time();
}
This way it would be obvious from the code that we are setting the publication date to current time only if it is the first version, and publicationDate has not been set manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are fine with me, and second is indeed more readable so +1 from me on that.
I'm lost in the conversation so I'll rather focus on this PR now and if there is any further questions beyond this PR we can find another time and place to deal with that. @iherak Had a second look here and in legacy, and added inline comment to suggest to adjust the approach slightly. However logic change is more or less what you suggests, just closer to how legacy does it and placing it in Should probably also add a BC not btw, even if this makes platform kernel behave closer to legacy. |
abff4ea
to
75ccb86
Compare
@andrerom I have added the note about the BC, please let me know if it's ok, or should I reword it or reformat it in some way. |
bc note is ok |
75ccb86
to
0bf6012
Compare
Is the PR's description up-to-date with the latest changes ? |
Yes, it is. |
89540d7
to
3378307
Compare
+1 on 3378307 |
@@ -174,6 +174,9 @@ Changes affecting version compatibility with former or future versions. | |||
|
|||
* Internal `limitationMap` repository service setting (for `RoleService`) has been renamed to `policyMap`. | |||
|
|||
* Published date of the content behaviour has been changed to reflect the time of the publishing of the first version. | |||
Before, if the publishedDate was not set manually, it was being set to the time of publishing the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to the publishing time of", or "to the latest version's publishedDate" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former. I can reword the note so it is more obvious.
+1 |
3378307
to
812dc9f
Compare
EZP-25377 fix republish modifying publication date
It's in @iherak, celebrate 🎆 ;) |
Great, thanks! |
Issue: https://jira.ez.no/browse/EZP-25377
When publishing existing content (creating new version) with the PAPI, the publication date of the content gets the current datetime, same as modification date. While modification date behavior is correct, the publish date of the content should remain unchanged to reflect the original (first) publish date of the content.
Publishing from legacy administration does just that - changes only modification date.
To reproduce:
Expected outcome: original content and republished content have the same publishedDate but different modificationDate.
Actual outcome: republished content has different publishedDate than original content.
I have added the regression test, but please do let me know if it's ok, and in the right place.