original_string: public static function delete_customfields_data(approved_contextlist $contextlist, string $component, string $area,
              string $itemidstest = 'IS NOT NULL', string $instanceidstest = 'IS NOT NULL', array $params = []) {
          global $DB;
  
          list($contextidstest, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED, 'cfctx');
          $sql = "SELECT d.id
              FROM {customfield_category} c
              JOIN {customfield_field} f ON f.categoryid = c.id
              JOIN {customfield_data} d ON d.fieldid = f.id AND d.instanceid $instanceidstest AND d.contextid $contextidstest
              WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest";
          $params = self::get_params($component, $area, $params) + $contextparams;
  
          self::before_delete_data('IN (' . $sql . ') ', $params);
  
          $DB->execute("DELETE FROM {customfield_data}
              WHERE instanceid $instanceidstest
              AND contextid $contextidstest
              AND fieldid IN (SELECT f.id
                  FROM {customfield_category} c
                  JOIN {customfield_field} f ON f.categoryid = c.id
                  WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest)", $params);
      }
code: public static function delete_customfields_data(approved_contextlist $contextlist, string $component, string $area,
              string $itemidstest = 'IS NOT NULL', string $instanceidstest = 'IS NOT NULL', array $params = []) {
          global $DB;
  
          list($contextidstest, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED, 'cfctx');
          $sql = "SELECT d.id
              FROM {customfield_category} c
              JOIN {customfield_field} f ON f.categoryid = c.id
              JOIN {customfield_data} d ON d.fieldid = f.id AND d.instanceid $instanceidstest AND d.contextid $contextidstest
              WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest";
          $params = self::get_params($component, $area, $params) + $contextparams;
  
          self::before_delete_data('IN (' . $sql . ') ', $params);
  
          $DB->execute("DELETE FROM {customfield_data}
              WHERE instanceid $instanceidstest
              AND contextid $contextidstest
              AND fieldid IN (SELECT f.id
                  FROM {customfield_category} c
                  JOIN {customfield_field} f ON f.categoryid = c.id
                  WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest)", $params);
      }
code_tokens: public static function delete_customfields_data ( approved_contextlist $ contextlist , string $ component , string $ area , string $ itemidstest = 'IS NOT NULL' , string $ instanceidstest = 'IS NOT NULL' , array $ params = [ ] ) { global $ DB ; list ( $ contextidstest , $ contextparams ) = $ DB -> get_in_or_equal ( $ contextlist -> get_contextids ( ) , SQL_PARAMS_NAMED , 'cfctx' ) ; $ sql = "SELECT d.id
              FROM {customfield_category} c
              JOIN {customfield_field} f ON f.categoryid = c.id
              JOIN {customfield_data} d ON d.fieldid = f.id AND d.instanceid $instanceidstest AND d.contextid $contextidstest
              WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest" ; $ params = self :: get_params ( $ component , $ area , $ params ) + $ contextparams ; self :: before_delete_data ( 'IN (' . $ sql . ') ' , $ params ) ; $ DB -> execute ( "DELETE FROM {customfield_data}
              WHERE instanceid $instanceidstest
              AND contextid $contextidstest
              AND fieldid IN (SELECT f.id
                  FROM {customfield_category} c
                  JOIN {customfield_field} f ON f.categoryid = c.id
                  WHERE c.component = :cfcomponent AND c.area = :cfarea AND c.itemid $itemidstest)" , $ params ) ; }
docstring: Deletes customfields data
  
  To be used in implementations of core_user_data_provider::delete_data_for_user
  Caller needs to transfer the $userid to the select subqueries for
  customfield_category->itemid and/or customfield_data->instanceid
  
  @param approved_contextlist $contextlist
  @param string $component
  @param string $area
  @param string $itemidstest subquery for selecting customfield_category->itemid
  @param string $instanceidstest subquery for selecting customfield_data->instanceid
  @param array $params array of named parameters for itemidstest and instanceidstest subqueries
docstring_tokens: Deletes customfields data