1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

As Designed Custom user field deletion does not delete entry data

Discussion in 'Resolved Bug Reports' started by rugk, Mar 3, 2016.

  1. rugk

    rugk Active Member

    When you delete a custom user field the data set by users for this field is not deleted from the database and can still be used by add-ons e.g.
    I doubt this is intended.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    There's code to remove the values via the _postDelete method of the DataWriter:
    PHP:
    $this->_db->delete('xf_user_field_value''field_id = ' $this->_db->quote($fieldId));
    // note the user caches aren't rebuilt here; this shouldn't be an issue as we don't enumerate them
    Unless you're talking about the cache of the field values in the xf_user_profile template, in which case this is expected (as suggested by the comment above).
     
  3. rugk

    rugk Active Member

    In my test it is just did not got deleted. I don't know whether this is caused by a cache.
    But after the user changes one of the other user fields after the deletion of the one field, the previously deleted field is also (correctly) deleted from $user['customFields'].
     
  4. Mike

    Mike XenForo Developer Staff Member

    This is expected an mentioned in the comment Chris quoted. You can rebuild user info if you really want to get rid of it, but there isn't an expectation that a field would be accessed that doesn't exist (and we never loop through the custom field cache for display).
     
  5. rugk

    rugk Active Member

    Okay, but if I have an add-on which uses this field, how can I check whether the field exists?
    array_key_exist does not really help, because it only checks the cache in this case.

    Feel free to move this post into the Dev-Support/Help section if you want to.
     
  6. rugk

    rugk Active Member

Share This Page