Problem/Motivation

When adding a block to a region (on page /admin/structure/block/list/seven, for example) the non-allowed characters (eg. whitespaces) in the human-readable name (eg. "Primary admin actions") are being left out resulting "primaryadminactions" machine name proposed.

However, when a similar operation is performed by adding a new menu to the site (on page /admin/structure/menu/add, for example) the same non-allowed characters (eg. whitespaces) in the human-readable name (eg. "This has multiple words") are replaced with a hyphen ("-") character resulting "this-has-multiple-words" machine name proposed, instead.

Screenshot comparison

This is confusing.

Proposed resolution

A unifyied, coherent logic should work on a site-wide level.

Remaining tasks

Discuss, Agree, Code, Patch, Commit, Documentate.

User interface changes

Note: this issue has nothing to do with the offered option to manually overwrite the automatically generated string proposal.

API changes

Machine names are highly important factor in Drupal's software architecture. Any changes being made on them should be thoroughly think over.

Comments

Balu Ertl created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

chi’s picture

Component: field system » base system
Issue summary: View changes
Issue tags: +DX (Developer Experience)

The machine names of blocks are really confusing. What makes it worse is that they cannot be changed afterwords. Eventually those names show up in names of preprocess hooks, Twig templates and config files.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Duncan.HY’s picture

Drupal seems to have a lot of issues with space, underscore, dash.

For space:
Space can have problems in many domains. Like variable name usually can't
have spaces and there are times space is used as deliminators ... etc.
So, it is understanable that space is not desired and dash and underscore
are equally good substitude.

For dash and underscore:
In general, I do not see good reason to eliminate either one of them -
both of them are in ASCII char. set. In general, except conventions,
prefrerances, consistancies ... etc. there really no reason to limited
one or the other.

Consistencies maybe preferred but I do not see it as required - the benefits
are most likely to make people's life easier without the need of checking
it all the time. On the other hand, it really would not break a system.

So, I think, unless there are real reason to eliminate one or the other,
I think we should allow boht since people has different needs - like transfer
things from other system and try to keep things consistent - or just the
preferences of people.

For low impact situations - like module names, which only cause incovience when
install or remove modules, I think we can try to make it consistense. But, on
the other hand, these really would not break the system or require a lot of
efforts to overcome.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.