Follow-up to #2329599: Update classList.js
Problem/Motivation
The version for one of our JavaScript libraries (classList) is not returned correctly in LibraryDiscoveryParser. It is defined as:
version: 2014-12-13
But when parsing the library file in LibraryDiscoveryParser::parseLibraryInfo(), this is parsed as a UNIX timestamp (1418425200):
Yaml::decode(file_get_contents($this->root . '/' . $library_file));
Versions should always be strings.
Proposed resolution
Explicitly cast all version numbers as strings by using double quotes for version numbers in the core.libraries.yml file.
Remaining tasks
Review patch
User interface changes
N/A
API changes
N/A
Comments
Comment #1
stefan.r commentedComment #2
andrewsuth commentedI'm at Drupal Dev Days and will fix this issue.
Comment #3
andrewsuth commented- Changed necessary library versions to strings in order to avoid YAML parsing conversions (in this case, it was found that an ISO date was converted to UNIX timestamp.
- Added a unittest to demonstrate the bug.
Comment #4
dom. commentedComment #5
stefan.r commentedConfirmed that all version numbers are double quoted in
core.libraries.ymlwhere possible, and that the bug with the invalid classList library version parsing has been fixed.Regardless of whether we fix the date casting issue elsewhere, it seems like good practice to always double quote version numbers in order to prevent similar issues in the future, so patch looks ready to me!
Comment #6
stefan.r commentedComment #7
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 127f0c8 and pushed to 8.0.x. Thanks!
Comment #9
neclimdulNot really a bug. Plain style (untagged) nodes like this are allowed to be resolved in this manner depending on the application. So pecl or symfony are allowed to define behaviors that allow this sort of resolution.
http://www.yaml.org/spec/1.2/spec.html#id2761292
The spec also documented how plain style ISO dates nodes can be resolved to timestamps.
http://www.yaml.org/spec/1.2/spec.html#id2761573
Comment #10
stefan.r commentedJust to be clear, the bug was the fact that the classList version was not returned correctly -- not the YAML parsing itself.