Problem/Motivation
This section is obsolete as it doesn't apply to Drupal 8 and beyond:
Persistent variables (variables/settings defined using Drupal's variable_get()/variable_set() functions) should be named using all lowercase letters, and words should be separated with an underscore. They should use the grouping/module name as a prefix, to avoid name collisions between modules.
Benefits
If we adopted this change, the Drupal Project would benefit by ...
Three supporters required
- {link to user}
- {link to user}
- {link to user}
Proposed changes
Provide all proposed changes to the Drupal Coding standards. Give a link to each section that will be changed, and show the current text and proposed text as in the following layout:
1. https://www.drupal.org/docs/develop/standards/php/php-coding-standards#s...
Current text
Add current text in blockquotes
Proposed text
Add proposed text in blockquotes
2. Repeat the above for each page or sub-page that needs to be changed.
Remaining tasks
Create this issue in the Coding Standards queue, using the defined template- List three supporters
- Create a Change Record
- Review by the Coding Standards Committee
- Coding Standards Committee takes action as required
- Tagged with 'Needs documentation edits' if Core is not affected
- Discussed by the Core Committer Committee, if it impacts Drupal Core
- Documentation updates
- Edit all pages
- Publish change record
- Remove 'Needs documentation edits' tag
- If applicable, create follow-up issues for PHPCS rules/sniffs changes
For a fuller explanation of these steps see the Coding Standards project page
Comments
Comment #2
avpadernoUntil Drupal 7 is still supported, that part is not obsolete.
Comment #3
joachim commentedIt should at least be changed to say it only applies to D7.
Comment #4
avpadernovariable_get()andvariable_set()are Drupal 7 functions. While it is not explicit that is about Drupal 7, and it could be made explicit, that should not be cause of misunderstanding so much to require a change before Drupal 7 stops to be supported.Comment #5
quietone commentedI have updated this issue to use the new Coding standard template. We are finding it very helpful.
Comment #7
quietone commentedI found a duplicate of this. It is suggesting;
.
I have closed that and am adding credit here.
Comment #8
quietone commentedNow that Drupal 7 is EOL, I think it is safe to remove all references to Drupal 7 specific standards.
Comment #9
quietone commentedAdd link to section to remove
Comment #10
avpadernoRather than removing that part, it should be updated to mention classes, methods, or functions the supported Drupal releases support.
Comment #11
joachim commentedThere isn't an exact replacement, and in any case, that's information about Drupal's APIs -- it doesn't belong in the coding standards.
Comment #12
avpadernoTruly, it is not an API requirement, since a module could call
variable_del()using a name for a persistent variable that module didn't define. Similarly, the state API, which is one of the replacements for the persistent variables API, does not require a module to use a specific state name.Comment #13
quietone commentedIs there any convention for the naming of State keys?
Comment #14
avpadernoThe state key names for state values created by Drupal core modules are prefixed by the module machine name followed by a period. Examples of those keys are system.cron_last, or comment.node_comment_statistics_scale.
Similar convention is used for the configuration object names. From automated_cron.settings, I gather the machine name of the module defining the configuration object.