On Fri, Dec 9, 2011 at 13:49, Vincent Massol
<vincent(a)massol.net> wrote:
On Dec 9, 2011, at 1:41 PM, Denis Gervalle wrote:
On Fri, Dec 9, 2011 at 10:17, Denis Gervalle
<dgl(a)softec.lu> wrote:
> Hi Devs,
>
> I am looking at now using the new Locale added in DocumentReference into
> the implementation of XWikiDocument.
> I have already deprecated language related stuff in XWikiDocument, and I
> have introduce a XWikiDocument#getLocale and an
XWikiDocument#isTranslation
> helper since the deprecation of
defaultLanguage will increase the need
of
> it. I have also added
XWikiDocument#getTranslatedDocument() with Locale
in
> place of language. All the changes are almost
backward compatible,
which is
> nice (there is some subtleties with default,
"" and null that is now
more
> equivalent, but should not have
consequences).
Make sure you move the deprecated sutff in -legacy if you can.
> The is however one change that is not
backward compatible, which is the
> change of the document reference. Therefore,
> XWikiDocument#getDocumentReference does not return the same reference
than
> it does before, because this reference now
contains the Locale. This
cause
> breakage in several places.
Why? It should be the same since the new ref only adds the optional locale.
> I see some option to fix this:
>
> A. Fix all places broken. This may be too long for me, and not trivial.
+1 if I understand correctly.
> B. Introduce a new
XWikiDocument#getDocumentReferenceWithLocale() and
> have XWikiDocument#getDocumentRefence() returns without Locale. Very
easy,
> but not nice.
Not nice -0
> C. Introduce a new
XWikiDocument#getDocumentReferenceWithoutLocale() and
> change all existing calls to XWikiDocument#getDocumentRefence() in
platform
> to use this one. Nicer, but this is not fully
backward compatible.
-0 till I understand the problem above.
I don't understand the issue.
The issue is simple, the DocumentReference will now contains one more
information, the Locale, and this could be unexpected in some place where a
more generic reference (without locale) is required. Therefore, in some
place, the comparison of a DocumentReference, with the one coming from a
document may return false negative, because the comparison is done with a
reference without Locale.
I should have precise that I am applying C with a some review of each
usage, to not replace massively where this seems not necessary, and keep as
much as possible getDocumentReference in preference to
getDocumentReferenceWithoutLocale.