Matrix Field provides a multi-valued field type (matrix_field) that stores sets of label / value / unit rows, managed as centrally configurable "matrices" of properties. It is designed for structured product characteristics (dimensions, specifications, nutrition facts) where the list of properties is managed once and reused across content. It ships with:

  • An administration UI for managing matrices, fields and groups
  • A field widget that renders one input per property
  • A formatter with grouping, units and human-readable Boolean values
  • A Search API processor exposing every property as a searchable field
  • An optional Feeds target sub-module (matrix_field_feeds)

Project link

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

Comments

gun_dose created an issue. See original summary.

vishal.kadam’s picture

Title: [2.0.0] Matrix field » [2.x] Matrix field
Issue summary: View changes
avpaderno’s picture

Issue summary: View changes

Thank you for applying!

Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.

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 smoother review.

The important notes are the following.

  • If you have not done it yet, you should enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
  • For the time this application is open, only your commits are allowed.
  • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

    Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
  • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
  • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

To the reviewers

Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.

The important notes are the following.

  • It is preferable to wait for a project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • It may be best to have the applicant fix things before further review.

For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.

vishal.kadam’s picture

Status: Needs review » Needs work

1. FILE: matrix_field.libraries.yml

version: VERSION

VERSION is only used by Drupal core modules. Contributed modules should use a literal string that does not change with the Drupal core version a site is using.

2. FILE: matrix_field.module

For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.

3. FILE: src/Drush/Commands/MatrixFieldCommands.php

  /**
   * The file system service.
   */
  protected FileSystemInterface $fileSystem;

  /**
   * The HTTP client.
   */
  protected ClientInterface $httpClient;

  /**
   * {@inheritdoc}
   */
  public function __construct(FileSystemInterface $file_system, ClientInterface $http_client) {
    parent::__construct();
    $this->fileSystem = $file_system;
    $this->httpClient = $http_client;
  }

FILE: src/Form/MatrixFieldsForm.php

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The pager manager.
   *
   * @var \Drupal\Core\Pager\PagerManagerInterface
   */
  protected $pagerManager;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * MatrixFieldsForm constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Pager\PagerManagerInterface $pager_manager
   *   The pager manager.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer.
   */
  public function __construct(
    EntityTypeManagerInterface $entity_type_manager,
    PagerManagerInterface $pager_manager,
    RendererInterface $renderer,
  ) {
    $this->entityTypeManager = $entity_type_manager;
    $this->pagerManager = $pager_manager;
    $this->renderer = $renderer;
  }

Modules which are compatible with Drupal 10 and higher versions are expected to use constructor property promotion.

gun_dose’s picture

Status: Needs work » Needs review

Thank you for the review. All three findings have been addressed in commit
3f2c6e7, pushed to the 2.x branch:

1. matrix_field.libraries.yml: the VERSION constant is reserved for core
modules and has been replaced with a literal version (2.4.0) for the
Multiple Select library, matching the upstream release that the bundled
Drush command downloads.

2. The Search API / facets / Page Manager cleanup logic has been moved out of
matrix_field.module into the new autowired service
matrix_field.search_api_field_cleanup
(Drupal\matrix_field\SearchApiFieldCleanup). The
matrix_field_matrix_field_delete() hook is now a thin wrapper around the
service. The hook itself is kept procedural on purpose: object-oriented
hook implementations (https://www.drupal.org/node/3442349) require
Drupal 11.1+, while this module supports ^10.2 || ^11 || ^12.

3. Constructor property promotion is now used in MatrixFieldCommands and
MatrixFieldsForm.

GitLab CI is configured on the 2.x branch (composer validation, phpcs with
Drupal + DrupalPractice, PHPStan with the drupal.org default configuration,
and the PHPUnit suite); phpcs and PHPStan currently report no issues, and
all 28 kernel/functional tests pass. All commits in the repository are my
own.

CI pipeline is green on the 2.x branch (composer-lint, phpcs, PHPStan, ESLint,
CSpell, PHPUnit). Latest commit: 3f2c6e7..cc4b971.

Setting back to Needs review.

avpaderno’s picture

Status: Needs review » Needs work
/**
 * Implements hook_help().
 */
function matrix_field_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the matrix_field module.
    case 'help.page.matrix_field':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides Matrix Field.') . '</p>';
      return $output;

    default:
  }
}

Hooks can be implemented as class methods even in Drupal 10.2. That is why in Support for object oriented hook implementations using autowired services; some ModuleHandler methods deprecated there is a section titled Backwards-compatible Hook implementation for Drupal versions from 10.1 to 11.0.

hook_help() should return something more than t('Provides Matrix Field.') which for a Matrix Field module does not make much sense, since it is saying the module provides… the module.

gun_dose’s picture

Status: Needs work » Needs review

Thank you for the review. Both points have been addressed in commit 920e2dd,
pushed to the 2.x branch:

1. All hooks (hook_help(), hook_theme(), hook_ENTITY_TYPE_delete()) are now
implemented as methods of the autowired service
Drupal\matrix_field\Hook\MatrixFieldHooks, following the backwards-compatible
pattern from https://www.drupal.org/node/3442349 ("Backwards-compatible Hook
implementation for Drupal versions from 10.1 to 11.0"): the class is
registered as an autowired service, the procedural implementations in
matrix_field.module are thin shims marked with the #[LegacyHook] attribute,
and the matrix_field.theme() preprocessing keeps using the "initial
preprocess" key.

2. hook_help() now returns a meaningful description of the module (what it
provides and how the matrices are used) with links to the administration
pages, instead of the meaningless "Provides Matrix Field." string.

The GitLab CI pipeline passes on the 2.x branch (phpcs, PHPStan, ESLint, CSpell
and PHPUnit report no issues).

Setting back to Needs review.

vishal.kadam’s picture

Priority: Normal » Major

I am changing priority as per Issue priorities.