Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
#2469431: BigPipe for auth users: first send+render the cheap parts of the page, then the expensive parts that LibraryDependencyResolver::getMinimalRepresentativeSubset()
may return a list rather than a set of libraries: i.e. it may return duplicates.
But this only happens if you pass in invalid data in the first place: if the input you pass in is already not a set.
Proposed resolution
Add an assertion that prevents that from happening, which then warns the developer the input is invalid.
Remaining tasks
Review.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#37 | 2594669-37.patch | 2.42 KB | borisson_ |
#21 | 2594669-21.patch | 2.65 KB | Wim Leers |
Comments
Comment #2
Wim LeersComment #3
Wim LeersBetter title.
Comment #4
Wim LeersComment #5
Wim LeersThe fact that this is merely a developer's mistake means this is not actually a bug, but a task.
Comment #7
Fabianx CreditAttribution: Fabianx for Acquia commentedGiven the test fails in HEAD, I think it is a bug?
Comment #8
Wim LeersI think all those failures are due to one and the same bug.
Comment #9
dawehnerI'm curious whether we could create a better asertion message. Many drupal developers are coming from backgrounds which might not be familiar with the property of sets you deal with here.
Comment #10
Wim LeersI think we can assume developers know one of the most basic data structures, that are even part of primary school math. I might be mistaken though.
Comment #11
Fabianx CreditAttribution: Fabianx as a volunteer commentedI tend to agree that set is pretty okay as error message, but better ideas welcome :).
Comment #12
catchAgreed with the other committers that this is an RC target, however:
1. Can we split adding the assert() to another issue, and leave this for the bug fix.
2. The test coverage looks incomplete?
Comment #13
xjmComment #16
Wim LeersSince this is no longer an RC target, I think it no longer makes sense to split this up.
Comment #17
catchIf it goes into 8.3.x yeah.
Comment #18
Wim LeersOf course.
Comment #19
alexpottThe assertion message doesn't seem to reflect what is being checked.
We use $this->setExpectedException() now..
Comment #20
dawehnerDoes it not? A set is a thing where each element is unique.
Comment #21
Wim LeersComment #23
catchI think it's worth some redundancy in the assertion method. There are dozens of colloquial meanings of 'set' in English, including things like 'set of cutlery' or 'chess set' which explicitly have duplicate items. So I'd go for "$libraries must be a unique set" or something more explicit.
Comment #24
Wim Leers"unique set" makes no sense at all.
What about:
$libraries must be a set data structure
?So, this: https://en.wikipedia.org/wiki/Set_(abstract_data_type). Funny enough, no set in SPL: http://php.net/manual/en/spl.datastructures.php.
Comment #27
Wim Leers@catch? :)
Comment #29
borisson_I think
$libraries can't contain duplicate items.
as an error message clearly states the intent without getting into semantics and helps developers understand what they need to do to resolve this.Comment #30
borisson_Comment #31
dawehnerI agree, this is a way nicer error message!
Comment #32
catchCommitted 60c25e5 and pushed to 8.6.x. Thanks!
Comment #34
Wim LeersI thought this went in a long time ago! 😅 Thanks @borisson_ for pushing it to completion!
Comment #36
catchThe assert is using the format deprecated in 7.2, so we need to update this one.
Comment #37
borisson_I think this satisfies #36.
Comment #38
Fabianx CreditAttribution: Fabianx as a volunteer commentedYep, back to RTBC
Comment #39
alexpottCommitted b8c09be and pushed to 8.6.x. Thanks!
Comment #41
alexpottOnly put in 8.6.x because we're just adding an assertion.
Comment #42
Wim LeersWFM 👍