If you have a field in the profile, and users fill in that field, and later that field is deleted all together, the entry in the profile_fields table is deleted, but the values for that field in profile_values aren't deleted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jmengle’s picture

FileSize
22.59 KB

Found where the field was deleted in profile.module and added a line to delete the field values from profile_values.

Uwe Hermann’s picture

Can you please provide a proper patch?

DriesK’s picture

Version: 4.6.0 » x.y.z
Status: Active » Needs review
FileSize
867 bytes

This is a patch of the db-cleanup code that jmengle added.

moshe weitzman’s picture

Status: Needs review » Needs work

please provide big red warning to admins before they do this. this is a very destructive operation.

Bèr Kessels’s picture

a default confirmation should do, imo.

Richard Archer’s picture

Status: Needs work » Needs review
FileSize
1.42 KB

Here's a revised patch that:

  • cleans up field values when the field is deleted
  • provides the user with a better warning message
  • offers the suggestion to make the field hidden if the field data should be retained

I shall attach a screen grab on another post.

Richard Archer’s picture

Screen grab of confirmation page.

Steve Dondley’s picture

you help text suggests making the fields hidden. How is it possible to make a profile field hidden?

Steve Dondley’s picture

Ah, OK, not hidden like a hidden HTML field. You'r talking about visibility setting in the profile module's field editing screen that says "Hidden profile field, only accessible by administrators, modules and themes."

I'd +1 this if you make that more clear and where this setting can be changed.

Richard Archer’s picture

Assigned: Unassigned » Richard Archer

Hey Steve,

Thanks for having a look at this patch. And a BIG thank you for taking the time to work out what I was talking about in that help text :)

Here's a new patch that applies cleanly against HEAD. The old patch was hit by the new forms API.

I have improved the warning message that appears once you hit "delete". It now reads:

Are you sure you want to delete the field Example?
This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to edit this field and change it to a "hidden profile field".

The text "edit this field" is a link to the admin page where they can change the type of the field.

Richard Archer’s picture

Hmm... can't upload the patch.

I'll upload it here when the site problem is fixed.
But here it is, for now:

http://mel01.juggernaut.com.au/del_profile_values_2.patch

Richard Archer’s picture

FileSize
1.79 KB

Patch attached.

Richard Archer’s picture

FileSize
1.84 KB

Here's a new version of this patch that applies cleanly and fixes some code style issues.

killes@www.drop.org’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, works as adertised.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Great team work guys. Committed to HEAD. Thanks.

Dries’s picture

Status: Fixed » Closed (fixed)