User login

Extending GDPR module's consent sub-module

If you add a GDPR Consent field to anything other than a node, user, or profile, it will result in a hard fail: "The website encountered an unexpected error. Please try again later."

The error in the logs is this:

drupal: http://example.local|1527607565|php|192.168.33.1|http://example.local/donate|http://example.local/admin/structure/give|1||Exception: Could not determine user ID for entity type give_donation. Please ensure there is a resolver registered. in Drupal\gdpr_consent\ConsentUserResolver\ConsentUserResolverPluginManager->getForEntityType() (line 96 of /vagrant/web/modules/contrib/gdpr/modules/gdpr_consent/src/ConsentUserResolver/ConsentUserResolverPluginManager.php).

The resolver they talk about is not a general one, but one that the GDPR module implements itself. When it does "getDefinitions()" for "ConsentUserResolverPluginManager" this is all it returns back:

Array
(
    [id] => gdpr_consent_node_resolver
    [label] => GDPR Consent Node Resolver
    [entityType] => node
    [class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\NodeResolver
    [provider] => gdpr_consent
)
Array
(
    [id] => gdpr_consent_user_resolver
    [label] => GDPR Consent User Resolver
    [entityType] => user
    [class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\UserResolver
    [provider] => gdpr_consent
)
Array
(
    [id] => gdpr_consent_profile_resolver
    [label] => GDPR Consent Profile Resolver
    [entityType] => profile
    [class] => Drupal\gdpr_consent\Plugin\Gdpr\ConsentUserResolver\ProfileResolver
    [provider] => gdpr_consent
)

So it seems pretty evident that for Give module's give_donation entity we need to implement a GDPR consent user resolver plugin ourselves.

Side note: determining an associated user is definitely something that should be part of Drupal's API, and not require any module to write its own code for it. It makes sense that the underlying core Entity class does not include a uid or reference to a user, but all content and profiles do so they should extend the same class or implement the same interface or something that would spare modules like GDPR this nonsense.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.