Problem

By default the module wipes out all fields on all entities. Sometimes it's desirable to leave some content in place.

Solution

Provide the possibility to specify a whitelist of fields/entities that don't need to be sanitized.

We provide a whitelist of entities that can be ignored instead of providing a list of entities that should be sanitized so that if new data is unknowingly added it is safely sanitized when nothing is done.

Original report

I haven't used this module yet, but this would be a great addition.

Also, FIRST!!!11!!!1!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frob created an issue. See original summary.

Kingdutch’s picture

Title: Add ability to Customize Field sanitation » Ability to whitelist fields/entities which don't need to be sanitized
Category: Task » Feature request
Issue summary: View changes

Changed issue title to reflect the purpose of this issue.

navneet0693’s picture

Status: Active » Needs review
FileSize
8.81 KB
Kingdutch’s picture

Status: Needs review » Needs work

In entity_sanitizer_drush_command

   // TODO DEBUG: LIMIT TO A SINGLE ENTITY/BUNDLE FOR EASE!
-//  $entities = ['node' => $entities['node']];
-//  $entities['node'] = ['page' => $entities['node']['page']];

Line 76, you've removed the examples on how to do quick debugging but you've not removed the debug comment that's not actually a TODO ^^'. Please either remove all three comment lines here or leave the example intact.

+      // TODO: Improve the logic to check existing keys.

Please create a ticket that describes what you dislike about the logic and create an issue in the issue queue that can be referenced.

In example.whitelist.yml

+# Don't sanitize node and user entity types
+user:
 node:
+  # Don't sanitize article bundle of node entity.
   article:
+  # Don't sanitize titles for the node article bundle
+  page:
     - title

Line 211, you're only skipping user into it's entirety so Don't sanitize user entities.
Line 214: Don't sanitize article bundle of node entities.
Line 216, you're working with the page bundle here: + # Don't sanitize titles for the node page bundle.

-# Don't sanitize price for the Product entity without bundles
+# Don't sanitize node and user entity types

Line 220, this change is incorrect, please revert it.

navneet0693’s picture

Status: Needs work » Needs review
FileSize
8.76 KB

Thanks @Kingdutch for review. I have added an improved patch. I will also add a follow-up issue once the patch is in.

Kingdutch’s picture

Status: Needs review » Needs work

Hi Navneet,

Please create the follow-up ahead of time so it can be added to the // TODO statement. Otherwise we'll have a TODO statement in 6 months and don't know what actually needs to happen.

Additionally, when making fixes to a patch it's good practice to create an interdiff which makes reviewing the newest changes easier :) See https://www.drupal.org/documentation/git/interdiff for more info.

~ Alexander

navneet0693’s picture

Status: Needs work » Needs review
FileSize
0 bytes
2.2 KB

Thanks @Kingdutch, I have added the follow-up issue link in todo and also have improved coding standards.

navneet0693’s picture

FileSize
9.33 KB

:facepalm:

for uploading an empty patch. I need more concentration:-P

  • Kingdutch committed 97188b5 on 8.x-1.x authored by navneet0693
    Issue #2966030 by navneet0693, Kingdutch: Ability to whitelist fields/...
Kingdutch’s picture

Status: Needs review » Fixed

Committed and tagged in 1.0-alpha10, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.