Took us a while to figure out that logic in #2221577: Fix assumption that field settings is not a nested array.
Attached patch:
- makes the prototype logic explicit,
- makes it clearer what the "prototype cache keys" are composed of,
- uses different var names for "the DataDefinition of the root object, used for prototype cache key", and "the DataDefinition of the object we want to create".
- changes Crypt::hashBase64() to crc32() for hashing the serialized settings, as per the discussion in #2346763: Improve views field rendering performance by caching entity display objects (see #10 & #13 over there)
Beta phase evaluation
Issue category | Task - clarifies & unifies some complex code |
---|---|
Issue priority | Normal |
Unfrozen changes | Unfrozen because it doesn't change any external behavior | Prioritized changes | The main goal of this issue is improve maintainability. This is not a prioritized change for the beta phase. |
Disruption | None |
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff.txt | 2.09 KB | yched |
#14 | 2364267-TDM_getPropertyInstance_cleanup-14.patch | 4.37 KB | yched |
#9 | interdiff.txt | 920 bytes | yched |
#9 | 2364267-TDM_getPropertyInstance_cleanup-9.patch | 4.2 KB | yched |
#1 | 2364267-TDM_getPropertyInstance_cleanup-1.patch | 3.93 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedPatch
Comment #2
yched CreditAttribution: yched commentedComment #3
andypostLooks great
Comment #4
alexpottThis issue is a normal task that intends to reduce fragility, and per #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?, we should discuss whether the benefit outweighs disruption. I would like to see a +1 from @fago or @berdir here as entity system maintainers (of which I assume typed data to be a part).
Personally I'm in favour of this issue because the discussions in #2221577: Fix assumption that field settings is not a nested array did reveal that this code is confusing.
Setting back to needs review to have said discussion.
Comment #5
yched CreditAttribution: yched commented@alexpott : I don't understand - this patch does not change the outside behavior of the method in any way.
Are we supposed to justify any internal code refactoring now ?
Comment #6
alexpott@yched yep - see #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase? for the allowed changes. There's a really good flowchart that explains it.
Comment #7
yched CreditAttribution: yched commentedOK - well I guess the definition of an internal refactor is "disruption = 0", so the "impact > disruption" criteria should be manageable :-)
Comment #8
BerdirI have to defer to @fago on this, he knows this part better and currently only have very limited core time, so I can't go into depth here.
But I see nothing with changing this in general.
Comment #9
yched CreditAttribution: yched commentedChanged Crypt::hashBase64() to crc32() for hashing the serialized settings, as per the discussion in #2346763: Improve views field rendering performance by caching entity display objects (see #10 & #13 over there)
Comment #10
yched CreditAttribution: yched commentedComment #11
andypost+1 to unify that kind of hashing
Comment #12
fagoIn general, +1 on the change. It makes the code clearer and easier to follow, but has no impact to the outside. Well unless people run into crc32 collisions now, but I think that's unlikely enough. ;-)
Here a review:
I cannot tell on which hashing algo to use, but looks like this has been discussed already. However, as it was something worth a discussion I think it also deserves a comment explaining our thinking.
The parenting information differs by clone and will be overwritting later by setContext() - thus it does not make sense to set it here. To avoid confusion it shoul be removed and rely on parenting info being set later.
Comment #13
fagoDiscussed 2. with yched on IRC. I wrongly assumed that the patch introduces the pass $object parameter, but it doesn't. Looking closer at it, we shoud keep it such that constructors have enough parenting information to setup objects. But as this is not obvious, let's have that documented here.
Comment #14
yched CreditAttribution: yched commentedShould adress #12 / #13
+ fixes a 80 chars wrapping issue in the previous patch.
Comment #15
yched CreditAttribution: yched commentedBump - @fago's remarks have been adressed, this just waiting for an RTBC.
Comment #16
amateescu CreditAttribution: amateescu commentedLooks great to me.
Comment #17
fagoNew comments are great, thanks. Agreed this is ready.
Comment #18
alexpottThis issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.
I think this internal refactoring is justified given the complexity of the code and moving to the consistent hashing for non cryptographic purposes makes sense too.
Comment #19
yched CreditAttribution: yched commentedTable added
Comment #20
alexpottThis patch makes this easier to maintain, consistent with other non cryptographic hashing and less fragile. Committed f503eb9 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.