Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-23526

Calling BaseClass#removeField(name) on a field and then BaseClass#addField(name, field) does not remove the field from the fields to remove list

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 17.7.0
    • Old Core
    • None
    • Unknown

    Description

      When someone removes a field from a class by calling BaseClass#removeField(name), and then adds this field back by calling BaseClass#addField(name, field), the field is added to fieldsToRemove by #removeField but not removed from it by addField, which can lead to issues.

      A workaround is to notice this and use getFieldsToRemove and #setFieldsToRemove. Documentation for these methods should probably be added to make it clear how they should be used and what for, including the fact that one can add or remove a field by modifying the returned list (i.e. getFieldsToRemove does not return a (immutable) copy of the list.

      By the way, is this list strictly necessary? Should it be indeed public?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rjakse Raphaƫl Jakse
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: