On 04/17/2010 10:17 AM, Vincent Massol wrote:
On Apr 17, 2010, at 3:47 AM, sdumitriu (SVN) wrote:
Author: sdumitriu
Date: 2010-04-17 03:47:52 +0200 (Sat, 17 Apr 2010)
New Revision: 28419
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
Log:
XWIKI-5121: Weird behavior when deleting the head of the history of a renamed document
Fixed.
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java 2010-04-17
01:23:30 UTC (rev 28418)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java 2010-04-17
01:47:52 UTC (rev 28419)
@@ -73,6 +73,10 @@
// If we delete the most recent (current) version, then rollback to
latest undeleted version.
if (!tdoc.getRCSVersion().equals(archive.getLatestVersion())) {
XWikiDocument newdoc =
archive.loadDocument(archive.getLatestVersion(), context);
+ // Reset the document reference, since the one taken from the
archive might be wrong (old name from
+ // before a rename)
+ newdoc.setDocumentReference(tdoc.getDocumentReference());
+ newdoc.setMetaDataDirty(false);
context.getWiki().getStore().saveXWikiDoc(newdoc, context);
context.setDoc(newdoc);
}
hmmm... when a doc is renamed, if we restore a version before the rename, shouldn't
we get back the old, not renamed, document?
Thought about it too, and I think that the answer is no.
The rename is not a version-able change. Looking in the history, there's
no indication that the document has been renamed, or that it used to
have a different name.
"Rename" is a meta-change, it alters the name with which a document
(seen as the information inside it) can be reached. Reverting the
document refers to reverting the information.
Think of the following use cases:
A document is create with a typo in its name. It survives like this for
a while, adding several revisions. After that, someone corrects the typo
in the name by renaming the document. Then, someone sees some bad edits
and wants to revert the document to its previous state. Is it OK to go
back to the old, wrong document name?
A document is created with a name. Not much activity in it, then someone
renames the document, and it stays like this for a long time. People get
accustomed to the new name and forget that it even had a different name
initially. Then someone reverts to the previous version. For the public,
the document disappeared, since nobody remembers the old name.
Now, IF the rename did appear in the history, and the user explicitly
deletes the "rename" change, I might be OK with moving back the
document, but in the current situation, I think that the implemented
behavior is the right one.
On a sidenote, we just deprecated the setDocumentReference method, since
we're not supposed to use it. Yet, I just did use it. What does this mean:
- there are valid usecases for setDocumentReference, or
- I should change the existing reference, like getDR().setName?
--
Sergiu Dumitriu
http://purl.org/net/sergiu/