Custom configuration management for a single site, Multi-domain & Multilingual.

This is a new module in Drupal 8/9/10. This module is more helpful where you want to save multiple configurations like Facebook, Twitter, Google Auth key and etc.

This module also works with multi-domain, multi-website and multilingual. This module provides the following functionality.

  • Create an unlimited number of configurations
  • Easy to use and understand
  • Access saved configuration by machine name
  • Set configuration as Active or Inactive, in case of inactive if you try to access the configuration it will return null
  • Provides service to access configuration value by machine name
  • If you are trying to access any non-exists machine name value, it will return null

Project link

https://www.drupal.org/project/custom_configuration

Comments

jeetmail72 created an issue. See original summary.

jitesh_1’s picture

Title: 10.0.1 [Custom Configuration] » [10.0.1] Custom Configuration

Thank you for applying! Reviewers will review the project files, describing what needs to be changed.

Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smother review.

To reviewers: Please read How to review security advisory coverage applications, What to cover in an application review, and Drupal.org security advisory coverage application workflow.

While this application is open, only the user who opened the application can make commits to the project used for the application.


Reviewers only describe what needs to be changed; they don't provide patches to fix what reported in a review.

vishal.kadam’s picture

Status: Needs review » Needs work

@jeetmail72 It seems you have missed working on the coding standards. You can use the PHPCS tool for checking and resolving issues.

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml custom_configuration/

FILE: custom_configuration/custom_configuration.info.yml
----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------
1 | WARNING | "core_version_requirement" property is missing in the info.yml file
----------------------------------------------------------------------------------------

FILE: custom_configuration/src/Form/ConfigurationSetting.php
--------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------
18 | ERROR | Missing member variable doc comment
--------------------------------------------------------------------------------------------

FILE: custom_configuration/src/Form/CustomConfigurationList.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
15 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------

FILE: custom_configuration/src/Form/DeleteConfiguration.php
-------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------
20 | ERROR | Missing member variable doc comment
21 | ERROR | Missing member variable doc comment
22 | ERROR | Missing member variable doc comment
-------------------------------------------------------------------------------------------

FILE: custom_configuration/src/Form/EditConfiguration.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
21 | ERROR | Missing member variable doc comment
22 | ERROR | Missing member variable doc comment
23 | ERROR | Missing member variable doc comment
73 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: custom_configuration/src/Helper/ConfigurationHelper.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 13 ERRORS AFFECTING 13 LINES
--------------------------------------------------------------------------------------------------------------------------------------------
159 | ERROR | The array declaration extends to column 119 (the limit is 80). The array content should be split up over multiple lines
185 | ERROR | The array declaration extends to column 102 (the limit is 80). The array content should be split up over multiple lines
199 | ERROR | The array declaration extends to column 119 (the limit is 80). The array content should be split up over multiple lines
202 | ERROR | The array declaration extends to column 101 (the limit is 80). The array content should be split up over multiple lines
227 | ERROR | The array declaration extends to column 119 (the limit is 80). The array content should be split up over multiple lines
243 | ERROR | The array declaration extends to column 112 (the limit is 80). The array content should be split up over multiple lines
246 | ERROR | The array declaration extends to column 108 (the limit is 80). The array content should be split up over multiple lines
251 | ERROR | The array declaration extends to column 125 (the limit is 80). The array content should be split up over multiple lines
254 | ERROR | The array declaration extends to column 107 (the limit is 80). The array content should be split up over multiple lines
259 | ERROR | The array declaration extends to column 102 (the limit is 80). The array content should be split up over multiple lines
369 | ERROR | The array declaration extends to column 105 (the limit is 80). The array content should be split up over multiple lines
372 | ERROR | The array declaration extends to column 101 (the limit is 80). The array content should be split up over multiple lines
497 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
--------------------------------------------------------------------------------------------------------------------------------------------

vishal.kadam’s picture

apaderno credited sleitner.

avpaderno’s picture

I am crediting users from the other applications.

avpaderno’s picture

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Priority: Normal » Minor
Status: Needs work » Postponed (maintainer needs more info)

Neither drupal-10.0.0 nor drupal10 are correct branch names.
The 10.0.1 branch the title suggest to review does not exist. Which branch should be reviewed?

I am changing priority as per Issue priorities.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

I am closing this application, since the person who created it does not seem to follow it.
I also asked which branch should be reviewed, but I did not get replies.

jeetmail72’s picture

Hi apaderno,

Sorry for the delayed reply.
Please find the branch name: 10.0.x

jeetmail72’s picture

Status: Closed (won't fix) » Needs review

Please review and grant the security advisory policy.

avpaderno’s picture

Title: [10.0.1] Custom Configuration » [10.0.x] Custom Configuration
avpaderno’s picture

Status: Needs review » Needs work
  • The following points are just a start and don't necessarily encompass all of the changes that may be necessary
  • A specific point may just be an example and may apply in other places
  • A review is about code that doesn't follow the coding standards, contains possible security issue, or doesn't correctly use the Drupal API; the single points aren't ordered, not even by importance

src/Form/ConfigurationForm.php

  /**
   * {@inheritdoc}
   */
  public function __construct(ConfigurationHelper $configHelper) {

{@inheritdoc} is not used in documentation comments for constructors, for which the description must start with Constructs a new followed by the class name (including its namespace), and end with object. Documentation comments for constructors must also describe the accepted parameters.

    if (!empty($machineName)) {
      $markup = $this->t('<div class="error_message custom-configuration_message"><font color="green">Machine name <strong><i>@name</i></strong>.</font></div>', [
        '@name' => $machineName,
      ]);
    }

The placeholder to render the string in <em> tags is @name.
HTML markup should be avoided as much as possible in strings passed to t() or $this->t().

    $return = $this->configHelper->createConfiguration($post);
    $this->messenger()->addMessage($this->t('@message', [
      '@message' => $return['message'],
    ]), $return['status']);

A string that contains only a placeholder is not translated. The output of $this->t('@message', ['@message' => 'Hello']) is not 'Ciao' when Italian is the selected language for the site; it is 'Hello' for every language.

src/Helper/ConfigurationHelper.php

  public function __construct(Connection $connection,
  ModuleHandler $moduleHandler,
  LanguageManager $languageManager,
  Container $serviceContainer) {

Method declarations are written on a single line.

  /**
   * Create machine name. Replace all characters except alpha & number.
   *
   * @param string $name
   *   Name will check and replace the string.
   *
   * @return string
   *   It will return the machine name.
   */
  public function createMachineName($name) {

Verbs used in the description must be declined to the third person singular. A definite article is missing before machine name.
Return value description must not starts with It will return, Returns, nor Return.

  /**
   * Return message for the error code.
   *
   * @param int $code
   *   Error code.
   */
  public function getMessageByCode($code) {

The description for the return value is missing.

   * @return bool|array
   *   It will return the configuration value.
   */
  public function getValues($machine_name = NULL, $langCode = NULL, $domainKey = NULL) {

The method does not return a Boolean value; it returns NULL. The description should say when NULL is returned.

Why is a custom database table used for configuration values, when Drupal has an API to store configuration values?

jeetmail72’s picture

@apaderno I am looking the points raised by you.

jeetmail72’s picture

Assigned: Unassigned » jeetmail72
vinaymahale’s picture

@jeetmail72, Also please make the 10.0.x branch as default branch. So it will be easy to review. Other reviewers will be confused about which branch needs to be reviewed.

vinaymahale’s picture

jeetmail72’s picture

Status: Needs work » Needs review

@vinaymahale I set the latest as the default branch.
@apaderno I fixed the issues as you mentioned in the comments. I used the custom table to keep the configuration independent but in the future, I will use Config Entity instead of the custom table.

Please find the latest code here git clone --branch '10.0.x' git@git.drupal.org:project/custom_configuration.git

vinaymahale’s picture

Looks good now! Let's wait for other reviewers!

vinaymahale’s picture

Assigned: jeetmail72 » Unassigned
hemangi.gokhale’s picture

Priority: Minor » Normal
Status: Needs review » Needs work

Automated Review

FILE: /var/www/html/web/modules/contrib/custom_configuration/src/Helper/ConfigurationHelper.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Language\LanguageManager.
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/custom_configuration/src/Form/CustomConfigurationList.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\custom_configuration\Helper\ConfigurationHelper.
------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/custom_configuration/src/Form/EditConfigurationForm.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Database\Connection.
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/custom_configuration/src/Form/DeleteConfigurationForm.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Database\Connection.
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Default Branch
Yes: Follows the guidelines for default branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements
Coding style & Drupal API usage
  1. src/Form/DeleteConfigurationForm.php
    class DeleteConfigurationForm extends ConfigFormBase {
       /**
        * Database connection object.
        *
        * @var \Connection
        */
       protected $database;
    

    there's no such thing called \Connection in Drupal, should be \Drupal\Core\Database\Connection instead.

  2. db_field_exists is used in custom_configuration.install, it is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call fieldExists() on it. For example, $injected_database->schema()->fieldExists($table, $field);
  3. hook_help doesn't contain much info.
  4. Why do we need README.txt, if there's already a README.md
  5. README.md says, This is new module in Drupal8, this can be improved or can be removed completely.

This review uses the Project Application Review Template.

avpaderno’s picture

Priority: Normal » Minor

I am changing priority as per Issue priorities.

jeetmail72’s picture

Status: Needs work » Needs review
Issue tags: +Deprecation Removal

I removed the deprecated function db_field_exists and fixed Drupal coding issues

avpaderno’s picture

Issue tags: -Deprecation Removal
avpaderno’s picture

Priority: Minor » Normal
avpaderno’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the Slack #contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the reviewers.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed
jeetmail72’s picture

Status: Fixed » Closed (fixed)
Issue tags: +Security Advisory follow-up

Thank you so much @apaderno

avpaderno’s picture

Status: Closed (fixed) » Fixed
Issue tags: -Security Advisory follow-up

We do not close issues, since they are automatically closed after 14 days.

Status: Fixed » Closed (fixed)

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