This is even more complex that I thought :)

In the AnnotationsTest in platform I had done:

        // Make sure Annotations and Comments are merged (this is not the 
default ATM!)
        getUtil().updateObject("AnnotationCode", "AnnotationConfig", 
"AnnotationCode.AnnotationConfig", 0,
            "activated", "0");

But I’ve found that AnnotationCode.Script actually checks the “activated” 
xproperty to decide if annotations are on or not (if off then you cannot add an 
annotation)…

So XWikiPreferences’s “activated” controls whether Comments and Annotations are 
merged while AnnotationCode.AnnotationConfig’s “activated” xproperty controls 
whether annotations are enabled or not…

Thanks
-Vincent

On 1 Sep 2015 at 17:37:16, [email protected] ([email protected]) wrote:

Hi,

Some analysis that took me time so I’m putting it here in case it helps someone 
and for us to consider changing the way this velocity parameter works.

Problem: I was moving the Annotation functional test from enterprise to 
platform and the test was failing because there are 2 Annotations entries 
displayed in the More Actions menu and the PageObjects picks the first one (the 
wrong one). This doesn’t show in XE, nor in an empty wiki.

Cause:

* If you’re in XE, then we provide a custom XWikiPreferences which has 
showannotations set to false. Thus Comments and Annotations are merged
* If you’re in an empty wiki, then there’s no XWikiPreferences but there’s also 
no AnnotationConfig page and thus this code in xwikivars.vm sets 
showannotations to false:

#retrieveSetting('showannotations' $settingValue)
#set ($showannotations = $settingValue)
#if ($showannotations)
  ## The general settings allow displaying the tab
  #set ($showannotations = false)
  #if ($xwiki.exists('AnnotationCode.AnnotationConfig'))
    #set ($annotationConfigObject = 
$xwiki.getDocument('AnnotationCode.AnnotationConfig').getObject('AnnotationCode.AnnotationConfig'))
    #if ($annotationConfigObject.getProperty('activated').value != 0 && 
!$annotationConfigObject.getProperty('exceptionSpaces').value.contains($doc.space))
      #set ($showannotations = true)
      #set ($annotationClass = 
$annotationConfigObject.getProperty('annotationClass').value)
      #set ($annotationCount = $doc.getObjects($annotationClass).size())
    #end
  #end
#end


* If you’re in the functional test of the annotation module. You don’t have 
XWikiPreferences but you do have an AnnotationConfig object and thus 
showannotations = true, thus displaying the 2 tabs: both the Comments tab and 
the Annotation tab.

Am I the only one to believe that Comments and Annotations should be merged by 
default, ie that by default showannotations = false without having to override 
it in XWikiPreferences? I guess we did this for backward compatibility? Can you 
imagine what problem we would have if we changed the default now?

Thanks
-Vincent


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to