- Issue created by @Input
- 🇳🇱Netherlands megachriz
This plugin was first implemented in #1028216: Hash of an item as GUID → .
From #1028216-3: Hash of an item as GUID → :
If a GUID is set, then this plugin does nothing, if a GUID is not set, then the GUID is set based on an MD5 hash of the import row.
So this translates to: if there already is a value, then don't modify it (return as is). If there is no value or if the "Override set value" option is enabled, then return a hash.
So I think that the implementation is correct. What could be improved is making clear that no hash is generated when the source provides a value unless the "Override set value" option is enabled. Perhaps add the following text on the form:
This plugin calculates a hash of the complete item in case the source doesn't already provide a value. This is useful for content that does not have a unique ID. Enable the option "Override set value" to always calculate a hash.
For reference, the D7 version of Feeds Tamper had the following help text for this plugin:
Makes the value a hash of the values being imported. This allows for importing content that does not have a unique ID.
Since Tamper can be used in other contexts beside Feeds, the terms "imported" and "importing" should at least be left out, because these make only sense in the context of Feeds.
- 🇩🇪Germany Input
In context of the origin it makes sence^^
Maybee it's an option tho change this to an feature request or discussion.
Implementation of the option "Create Hash from fields value" (Not complete row) analog to "Makes the value a hash of the values of item (row) being tampered."
This a least just a "simple" extension. For my desired and original understood behaviour one has to implement a complete plugin-module, which is a full copy of Hash.php except one line (return $data changed to return md5(serialize($data)); ), which is somehow complete overdose.
- 🇳🇱Netherlands megachriz
Hm, I think that I don't get your issue. Why do you need to make a copy of the plugin with one thing changed? The plugin essentially has two modes:
- Return a hash only if the source value is empty ("Override set value" option disabled - the default)
- Always return a hash ("Override set value" option enabled)
Which mode are you missing?
- 🇩🇪Germany Input
I'm missing the mode: create hash from given data/field value. Not like curerntly implemented: Hash the items source (row) if empty/setting applied else return data as is.
Usecase would be in combination with Feeds/ Feeds_Tamper:
I have multiple feeds (json im my case):
- Feed 1: Collection of Image URLs (no uuids provided, as actually this is some cases the same feed as e.g. Feed 2)
- Feed 2 to X: Collection of Nodes containing an property "flyer_url" which can be multiple times one out of Feed 1Images from Feed 1 are created as Media-Entity. As I need some guid later and have none yet the only option is to create one. As PoC the URL is enough for it, but it's an Information not wanted in this way. So hashing it is best. Creating the hash from the full feed-item does not work in this context as stated below.
Reason it does not work:
Feeds 2 to X only contain the original image url. With the same intention in mind, that the full (old) url inside the db is an information without value an the has of it fullfills the perfect need, the same hashing like in Feed 1 comes into it. On Feed2 the hash-value is used to reference to the created Media-Entity via Feed-Element: Element GUID from Feed1. Currently the Hash function will create a hash over the full node entity, which will not map to the hash of the media feed guidIn this context a "Hash-Function" is a function generating a hash and not a function, which only checks if something is empty or creates a hash over a full dataset instead of a single value within this dataset. Also the current implementation "assumes" the given value is already a hash.
Same thing could apply if e.g. your uuids you have to create is a combination lets say of hashed username+email, which for shure should not be used as guuid plaintext.
Maybe you get what's in my mind.
- 🇳🇱Netherlands megachriz
Okay, I think I'll get it. In that case, I think the best is to add an option of what the hash should be made of:
- Create a hash of the whole item (the default, for backwards compatibility)
- Create a hash of the value
- Create a hash of the following selected fields: []
And we need the following option for backwards compatibility:
- Only hash if empty (else leave the value unchanged)
Meanwhile I found this Feeds Tamper D7 issue where one patch implements the option "Create a hash of the following selected fields" and the other one "Create a hash of the value": #1297650: hash over only the chosen sources → .
And I turn this into a feature request.
- 🇩🇪Germany Input
I also think adding an option in this way keeps combatibility beside it's an ggod enhancement.
Thank you very much.