Skip to content

XWIKI-21417: BaseObject#set always set the metadata dirty flag of the owner doc to true #4064

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

surli
Copy link
Member

@surli surli commented Apr 17, 2025

Jira URL

Changes

Description

  • Provide a new API to retrieve current property or create a new one, use that call in all fromString and fromStringArray methods

Clarifications

Screenshots & Video

Executed Tests

Ran mvn clean install -Pquality on both oldcore and legacy-oldcore and executed docker test in xwiki-platform-appwithinminutes-test-docker.

⚠️ However we need dedicated unit test and at least a manual test.

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • No: feels too dangerous for backport

… owner doc to true

  * Provide a new API to retrieve current property or create a new one,
    use that call in all fromString and fromStringArray methods
@surli surli self-assigned this Apr 17, 2025
… owner doc to true

  * Introduce new generic APIs allowing to set given BaseProperty values
    and provide implementations
@surli surli requested a review from tmortagne April 22, 2025 14:51
* Retrieve the already existing base property based on current name, or create a new one.
*
* @return the existing {@link BaseProperty} or a new one.
* @since 17.3.0RC1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be updated.

@@ -366,7 +366,7 @@ public void set(String fieldname, java.lang.Object value, XWikiContext context)
PropertyClass pclass = (PropertyClass) bclass.get(fieldname);
BaseProperty prop = (BaseProperty) safeget(fieldname);
if ((value instanceof String) && (pclass != null)) {
prop = pclass.fromString((String) value);
prop = pclass.fromString((String) value, prop);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's really the cleanest code in general, it's good to reuse the property, but it's a bit strange to re-put it in the object.

@Unstable
protected BaseProperty getCurrentOrNewProperty(BaseProperty property)
{
return (property != null) ? property : newProperty();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be outside the scope of this issue, but I'm wondering if the xclass should "auto-repair" the property if it does not have the right type. Right now, the following code might fail if getCurrentOrNewProperty gives a property of the wrong type (compared to the previous situation where that code was expecting to always get a new property).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants