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.
At the moment Drupal\path\Plugin\Field\FieldType\PathItem::generateSampleValue()
generates a path that doesn't start with a slash causing errors like Alias path demo-alias-without-a-slash. has to start with a slash
when saving the node.
I've attached a patch with the fix and a test, also a failing test without the fix.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2944215-7.patch | 1.56 KB | alexpott |
#7 | 1-7-interdiff.txt | 564 bytes | alexpott |
alias-sample-value-with-slash.patch | 1.55 KB | jeqq | |
alias-sample-value-with-slash-test_only_should_fail.patch | 916 bytes | jeqq | |
Comments
Comment #2
jeqqComment #3
jeqqComment #5
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation for Pfizer, Inc. commentedThe fix simple enough, and the test covers the bug, and is easy to follow. Only one nitpick from me:
+++ b/core/modules/path/tests/src/Kernel/PathItemTest.php
@@ -189,6 +189,18 @@ public function testPathItem() {
+ // Test the generateSampleValue() method.
We can make it clearer as to what we are testing here, something like:
Comment #6
timmillwoodNice find @jeqq, looks good to me!
Comment #7
alexpottI'm not that convinced by #5 but this assertion should be:
Since PHPUnit will give far better errors with that.
Comment #8
alexpottCommitted and pushed b5a5c68129 to 8.6.x and f4fd08a7e3 to 8.5.x. Thanks!
Backported to 8.5.x since this bug-fix is extremely low risk and tested.