Created
October 30, 2019 13:52
-
-
Save MGHollander/d0c1fd79c625981ec25d20348db1a52c to your computer and use it in GitHub Desktop.
Drupal 7 custom drush sanitization hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_drush_sql_sync_sanitize. | |
*/ | |
function MY_MODULE_drush_sql_sync_sanitize($source) { | |
// Sanitize username | |
$users_query = "UPDATE users SET name = CONCAT('name', uid) WHERE uid > 1;"; | |
drush_sql_register_post_sync_op('sanitise_users_name', dt('Sanitise users name field'), $users_query); | |
// Sanitize field | |
$field_lastname_query = "UPDATE field_data_field_lastname SET field_lastname_value = CONCAT('lastname', entity_id) WHERE entity_id > 1;"; | |
drush_sql_register_post_sync_op('sanitise_field_lastname', dt('Sanitise lastname field'), $field_lastname_query); | |
// Also sanitize revision field | |
$field_revision_lastname_query = "UPDATE field_revision_field_lastname SET field_lastname_value = CONCAT('lastname', entity_id) WHERE entity_id > 1;"; | |
drush_sql_register_post_sync_op('sanitise_field_revision_lastname', dt('Sanitise lastname revision field'), $field_revision_lastname_query); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment