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

  1. Convert paths in tests from under_score to hyphen-ated.
  2. Run tests locally to make sure they fail.
  3. Convert paths in *.routing.yml files from under_score to hyphen-ated.
  4. 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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Morbus Iff created an issue. See original summary.

marvil07’s picture

Issue tags: +Novice

Thanks for the suggestion!

I completely agree, consistency is really important in a project like this.

Patches are welcome.

Mile23’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Issue summary: View changes

Good 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.

rashid_786’s picture

Assigned: Unassigned » rashid_786
Devaraj johnson’s picture

I have updated the patch

Devaraj johnson’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: hyphen-for-paths-2661834-5.patch, failed testing.

Devaraj johnson’s picture

fixed the issues in the test files

Devaraj johnson’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: hyphen-for-paths-2661834-8.patch, failed testing.

sdstyles’s picture

Status: Needs work » Needs review
FileSize
48.22 KB

Status: Needs review » Needs work

The last submitted patch, 11: hyphen-for-paths-2661834-11.patch, failed testing.

rashid_786’s picture

Assigned: rashid_786 » Unassigned
anand.toshniwal93’s picture

Assigned: Unassigned » anand.toshniwal93
Issue tags: +drupalconasia2016
anand.toshniwal93’s picture

Assigned: anand.toshniwal93 » Unassigned
kavbiswa’s picture

Assigned: Unassigned » kavbiswa
navneet0693’s picture

Assigned: kavbiswa » navneet0693
navneet0693’s picture

navneet0693’s picture

Hi Mile23,

I am somehow unable to add test results for the patch I have submitted. Testing results on my local are OK.

Mile23’s picture

Status: Needs work » Needs review

Set the issue to 'Needs review' and the patch will be sent to the testbot.

Status: Needs review » Needs work

The last submitted patch, 18: core_uses_hyphen_for-2661834-18.patch, failed testing.

Mile23’s picture

And then of course we have to 'add test' and switch the testbot to use the proper version of core.

The last submitted patch, 18: core_uses_hyphen_for-2661834-18.patch, failed testing.

navneet0693’s picture

navneet0693’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 24: core_uses_hyphen_for-2661834-24.patch, failed testing.

navneet0693’s picture

Status: Needs work » Needs review

Link 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

Mile23’s picture

The 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.

navneet0693’s picture

Awesome ! 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.

Nikhil Banait’s picture

Reviewed patch core_uses_hyphen_for-2661834-24.patch. It's working fine.

navneet0693’s picture

Assigned: navneet0693 » Unassigned
Mile23’s picture

Status: Reviewed & tested by the community » Postponed

#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.

Mile23’s picture

Status: Postponed » Needs review

#2686591: Consolidate fapi_example tests into one test class is in, so:

Setting to needs review, restarting the test for #24.

Status: Needs review » Needs work

The last submitted patch, 24: core_uses_hyphen_for-2661834-24.patch, failed testing.

navneet0693’s picture

Assigned: Unassigned » navneet0693

Merging 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.

navneet0693’s picture

This patch also includes changes in FapiExampleWebTest.php

navneet0693’s picture

Assigned: navneet0693 » Unassigned
Chi’s picture

As 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.

Morbus Iff’s picture

This issue isn't really meant to fix content type paths, but rather to fix user-coded paths, which Drupal 8 still uses hyphens for.

Mile23’s picture

Status: Needs review » Needs work

I 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:

+++ b/content_entity_example/src/Tests/ContentEntityExampleTest.php
@@ -227,18 +227,16 @@ class ContentEntityExampleTest extends ExamplesTestBase {
     $this->drupalLogin($web_user);
-    $entity_name = 'content_entity_example_contact';
-    $add_field_url = 'admin/structure/' . $entity_name . '_settings/fields/add-field';
+    $add_field_url = 'admin/structure/content-entity-example-contact-settings/fields/add-field';
     $this->drupalGet($add_field_url);
-    $field_name = 'test_name';
     $edit = array(
       'new_storage_type' => 'list_string',
       'label' => 'test name',
-      'field_name' => $field_name,
+      'field_name' => 'test_names',
     );

Unneeded changes. Let's just work on the hyphens and not the variables.

Make a follow-up issue if other changes are needed.

navneet0693’s picture

Assigned: Unassigned » navneet0693
navneet0693’s picture

Referring to #41 and to https://www.drupal.org/node/1574668, I have done the necessary changes.

Shreya Shetty’s picture

Status: Needs review » Reviewed & tested by the community

This patch works fine .. Good to go :)

navneet0693’s picture

Assigned: navneet0693 » Unassigned

  • marvil07 committed 31f1762 on 8.x-1.x authored by navneet0693
    Issue #2661834 by navneet0693, Devaraj johnson, sdstyles, Mile23: Core...
marvil07’s picture

Status: Reviewed & tested by the community » Fixed

This is a lot of work, thanks to all the contributors of this issue!
I have just added it to 8.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.