Problem/Motivation
Core has used dashes for URL paths forever. It had in D6, it had in D7, and it continues to do so in D8.
Historically this was likely because, once upon a time, hyphens were considered better separators in a URL path than underscores. Nowadays, it doesn't really matter. However, there should be consistency between Core and Contributed modules, and thus all Example content should be modified to use hyphens instead of underscores (see block_example.routing, content_example.routing., etc.).
Proposed resolution
- Convert paths in tests from
under_score
tohyphen-ated
. - Run tests locally to make sure they fail.
- Convert paths in
*.routing.yml
files fromunder_score
tohyphen-ated
. - Run tests to make sure they pass.
Code that isn't a test should not specify paths. (Should specify routes.)
But if we end up finding code that does, we can either convert the path to a route, or just change the path if it's unclear what to do. The latter case gets a follow-up if we find any.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#43 | core_uses_hyphen_for-2661834-43.patch | 49.82 KB | navneet0693 |
#37 | core_uses_hyphen_for-2661834-37.patch | 55.94 KB | navneet0693 |
#24 | core_uses_hyphen_for-2661834-24.patch | 57.87 KB | navneet0693 |
#18 | core_uses_hyphen_for-2661834-18.patch | 58.31 KB | navneet0693 |
#11 | hyphen-for-paths-2661834-11.patch | 48.22 KB | sdstyles |
Comments
Comment #2
marvil07 CreditAttribution: marvil07 as a volunteer commentedThanks for the suggestion!
I completely agree, consistency is really important in a project like this.
Patches are welcome.
Comment #3
Mile23Good idea.
Let's do this for 8.x-1.x first, and then backport.
Updated the issue summary with instructions. Suitable for Novice so I'm leaving the tag.
Comment #4
rashid_786 CreditAttribution: rashid_786 at SDG Corporation commentedComment #5
Devaraj johnson CreditAttribution: Devaraj johnson as a volunteer and at Ameex-Drupal Geeks commentedI have updated the patch
Comment #6
Devaraj johnson CreditAttribution: Devaraj johnson as a volunteer and at Ameex-Drupal Geeks commentedComment #8
Devaraj johnson CreditAttribution: Devaraj johnson as a volunteer and at Ameex-Drupal Geeks commentedfixed the issues in the test files
Comment #9
Devaraj johnson CreditAttribution: Devaraj johnson as a volunteer and at Ameex-Drupal Geeks commentedComment #11
sdstyles CreditAttribution: sdstyles at FFW commentedComment #13
rashid_786 CreditAttribution: rashid_786 at SDG Corporation commentedComment #14
anand.toshniwal93 CreditAttribution: anand.toshniwal93 as a volunteer and at QED42 commentedComment #15
anand.toshniwal93 CreditAttribution: anand.toshniwal93 as a volunteer and at QED42 commentedComment #16
kavbiswa CreditAttribution: kavbiswa commentedComment #17
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #18
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #19
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedHi Mile23,
I am somehow unable to add test results for the patch I have submitted. Testing results on my local are OK.
Comment #20
Mile23Set the issue to 'Needs review' and the patch will be sent to the testbot.
Comment #22
Mile23And then of course we have to 'add test' and switch the testbot to use the proper version of core.
Comment #24
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #25
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #27
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedLink to Dispatcher : https://dispatcher.drupalci.org/job/default/120636/console
Drupal CI is throwing an error ;
PHP Fatal error: Class 'Drupal\field\Tests\FieldUnitTestBase' not found in /var/www/html/modules/examples/field_permission_example/src/Tests/FieldNoteItemTest.php on line 22
Testing is dependent on : Issue #2690403 https://www.drupal.org/node/2690403
Comment #28
Mile23The problem here is that the test classes provided by core changed around. Drupal 8.2.x has different test classes than 8.1.x (more or less).
Also, when you switch a patch to 'needs review,' the testbot automatically tests against the latest *dev* version of Drupal core. In this case, 8.2.x. You can see it in the test result in #24.
The target version of core for the Examples project is the latest stable release, which is 8.1.0. Since we can't specify that, 8.1.x will have to do.
So if we re-start the test, and choose 8.1.x as the version of core we want to test against, we'll (probably) get a test run that at least runs, rather than erroring out.
We click on 'add test' and add it. I'll do it now. Let's see what happens.
Comment #29
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedAwesome ! I will be careful while choosing the test against version of drupal. The test has been passed, let us wait for someone to review it.
Comment #30
Nikhil Banait CreditAttribution: Nikhil Banait as a volunteer and at QED42 commentedReviewed patch core_uses_hyphen_for-2661834-24.patch. It's working fine.
Comment #31
Nikhil Banait CreditAttribution: Nikhil Banait as a volunteer and at QED42 commentedComment #32
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #33
Mile23#2690403: Fatal error: Class 'Drupal\field\Tests\FieldUnitTestBase' not found is committed. Yay.
Let's postpone this issue until #2686591: Consolidate fapi_example tests into one test class is committed, since we need the tests to work for the reroll.
Comment #34
Mile23#2686591: Consolidate fapi_example tests into one test class is in, so:
Setting to needs review, restarting the test for #24.
Comment #36
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedMerging of #2686591: Consolidate fapi_example tests into one test class has lead to removal of test files, that's why the drupalci results so (patch faild to apply), I am working to recreate this accordingly.
Comment #37
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedThis patch also includes changes in FapiExampleWebTest.php
Comment #38
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #39
Chi CreditAttribution: Chi commentedAs an aside, is there some Drupal standard about the subject? I could not find any. Drupal 8 does not convert underscores to hyphens in machine names when they are part of URL. Here is an issue for content types: https://www.drupal.org/node/1574668.
Comment #40
Morbus IffThis issue isn't really meant to fix content type paths, but rather to fix user-coded paths, which Drupal 8 still uses hyphens for.
Comment #41
Mile23I think 'be like core' is a worthy idea.
I also think it would be super awesome if we could refer to an issue or change notice explaining why core does it this way.
That said, here's a review:
Unneeded changes. Let's just work on the hyphens and not the variables.
Make a follow-up issue if other changes are needed.
Comment #42
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #43
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedReferring to #41 and to https://www.drupal.org/node/1574668, I have done the necessary changes.
Comment #44
Shreya Shetty CreditAttribution: Shreya Shetty commentedThis patch works fine .. Good to go :)
Comment #45
navneet0693 CreditAttribution: navneet0693 as a volunteer and at QED42 commentedComment #47
marvil07 CreditAttribution: marvil07 as a volunteer commentedThis is a lot of work, thanks to all the contributors of this issue!
I have just added it to 8.x-1.x.