While working on required rights, I noticed that the hidden status of a page is always updated when the page is updated via the REST API. This means that when you don’t specify the hidden status, it is implicitly set to false
. This even concerns the API that uses an application/x-www-form-urlencoded
body. I’ve created XWIKI-22336 for this issue. On the other hand, when just specifying the hidden status in a page update request in the REST API, the page isn’t saved, this is XWIKI-22337.
In order to fix this, we need to be able to distinguish between three values of the hidden field: true
, false
and not set. Currently, the org.xwiki.rest.model.jaxb.Page.hidden
field that is used to represent the received data is of type boolean
so it cannot represent that “not set” state. I propose to change this field to Boolean
such that we can properly distinguish between the three values. This results in the following breakages:
[ERROR] java.field.typeChanged: field org.xwiki.rest.model.jaxb.Page.hidden: The type of the field changed from 'boolean' to 'java.lang.Boolean'. https://revapi.org/revapi-java/differences.html#java.field.typeChanged
[ERROR] java.annotation.removed: field org.xwiki.rest.model.jaxb.Page.hidden: Element no longer annotated with 'javax.xml.bind.annotation.XmlElement'. https://revapi.org/revapi-java/differences.html#java.annotation.removed
[ERROR] java.method.returnTypeChanged: method java.lang.Boolean org.xwiki.rest.model.jaxb.Page::isHidden(): The return type changed from 'boolean' to 'java.lang.Boolean'. https://revapi.org/revapi-java/differences.html#java.method.returnTypeChanged
[ERROR] java.method.parameterTypeChanged: parameter void org.xwiki.rest.model.jaxb.Page::setHidden(===java.lang.Boolean===): The type of the parameter changed from 'boolean' to 'java.lang.Boolean'. https://revapi.org/revapi-java/differences.html#java.method.parameterTypeChanged
[ERROR] java.method.parameterTypeChanged: parameter org.xwiki.rest.model.jaxb.Page org.xwiki.rest.model.jaxb.Page::withHidden(===java.lang.Boolean===): The type of the parameter changed from 'boolean' to 'java.lang.Boolean'. https://revapi.org/revapi-java/differences.html#java.method.parameterTypeChanged
This vote is about accepting this breakage. I thought this breakage was acceptable because this Page
object isn’t supposed to be used outside the REST API. However, I then noticed that it is in fact used in REST clients. Thanks to autoboxing and unboxing, no actual code changes are necessary but if a code is compiled against one version of the Page
object and uses the hidden field, it won’t work with the updated version. I’m thus not sure anymore if the breakage is really acceptable.
If you have any idea how to avoid this breakage, please let me know. You can see an implementation of the proposed changes at XWIKI-22336: Updating a page with the REST API makes it non-hidden unless the hidden property is specified by michitux · Pull Request #3282 · xwiki/xwiki-platform · GitHub.
I’ll leave this vote open for a full week until July 25th (included).
1 post - 1 participant