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
Yet another bug unveiled by #2590993: Create stub entities with proper default values! We use generateSampleValue() to fill in stubs for referenced entities during migrate, and an entity with a uri field fails validation because the value is something like swuuobrouutidis... The problem is that UriItem does not implement generateSampleValue(), so it falls through to StringItem::generateSampleValue().
Proposed resolution
Implement UriItem::generatSampleValue() to produce a valid uri.
Remaining tasks
Do it, with a test.
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#4 | 2605150-4.patch | 1.59 KB | mikeryan |
#4 | 2605150-4-FAIL.patch | 556 bytes | mikeryan |
Comments
Comment #2
mikeryanTried to start with a unit test to demonstrate the failure, but got hung up trying to figure out how to mock the pieces to get me a field definition to pass generateSampleValue(). So, for now, here's just a fix without a test...
Comment #3
mikeryanAiming for RC because without it we'll need a work-around in #2590993: Create stub entities with proper default values.
Comment #4
mikeryanMost of the other primitive types had tests for generateSampleValue(), added one to UriItemTest. That test seems rather thin generally compared to the other field types, but out-of-scope for this immediate issue...
Comment #7
mikeryanThat's better.
Comment #9
Wim LeersLooks great. Uses
\Drupal\Component\Utility\Random::word()
, therefore it will always generate valid hostnames.Comment #11
webchickD'oh. Nice catch. Speaking of catch, showed this to him and he felt it was fine to get in during RC, so making an RC target.
Committed and pushed to 8.0.x. Thanks!