public static function delete_customfields_data_for_context(string $component, string $area, \context $context) {
        global $DB;

        $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
            JOIN {context} ctx ON ctx.id = d.contextid AND ctx.path LIKE :ctxpath
            WHERE c.component = :cfcomponent AND c.area = :cfarea";
        $params = self::get_params($component, $area, ['ctxpath' => $context->path . '%']);

        self::before_delete_data('IN (' . $sql . ') ', $params);

        $DB->execute("DELETE FROM {customfield_data}
            WHERE 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 contextid IN (SELECT id FROM {context} WHERE path LIKE :ctxpath)",
            $params);
    }