Updated: Comment #N

Problem/Motivation

From #731724: Convert comment settings into a field to make them work with CMI and non-node entities

Disregarding the concrete use-case: Architecturally, this concept is badly needed in Drupal.

This concrete sample implementation will be copied + resembled by 1,000+ contributed and custom modules.

All major concerns and objections that have been raised are 100% valid. It would be a huge mistake to ignore them.

Some of the concerns are about fundamental concepts (content vs. configuration-ish meta data).

The current/previous implementation is only acceptable, because the meta data is, in fact, not part of the actual content entity that is being processed in various ways. Instead, the additional meta data is pulled in and used where needed and where appropriate only.

The proposed change turns the formerly separate meta data into data of the content itself — implicitly participating in all possible content entity interactions, even though the data is not content.

We're seeing this anti-pattern and inappropriate (ab)use of architecture in plenty of contributed modules already.

A prime example might be the Media module (adding internal meta data fields to all entity types/bundles that it is operating with). That inappropriate usage is the topmost reason for why a proper architectural solution in Drupal core is required.

Ultimately, the conflict stems from the fact that we happen to have an architecture in core that happens to fully resolve the needs of affected modules.

From a technical standpoint, it delivers a 99% solution. But from a conceptual and business logic perspective, the solution is 100% incompatible and inappropriate to use.

Business logic matters.

The good news: All of the code exists already. Including tests.

Consequently, what you want to do is this:

$ cp -R core/modules/field core/modules/metadata
$ find core/modules/metadata -type f -exec sed -i "s/field_/metadata_/g;s/Field/Metadata/g" '{}' ';'
In words: Literally copy the whole shebang. Apparently, it solves plenty of hard problems for contrib. You have the solution right in your hands, you can provide it.

You want to diverge from the Field API mainline, because of the very valid concerns that have been raised with regard to differences in business logic. These fields != fields, but yet, == fields.

You can further consider to simplify the Meta Data API afterwards; e.g., by restricting storage to SQL (debatable; separate discussion), and/or possibly removing any other complexities of Field API that are irrelevant (e.g., multiple values).

Regardless of these major conceptual and architectural concerns, I do support this change. It is required, and it attacks one of the most critical bottlenecks in Drupal's architecture.

Unless core provides a proper solution, the world will continue to abuse existing APIs in utterly inappropriate ways, further disrupting a clear and common understanding of what exactly "content" constitutes.

Drupal has to have a solid architectural concept for this data. Core consumers badly need a solution, yesterday.

Proposed resolution

$ cp -R core/modules/field core/modules/metadata
$ find core/modules/metadata -type f -exec sed -i "s/field_/metadata_/g;s/Field/Metadata/g" '{}' ';'

Remaining tasks

Talk this through
Discuss
Etc
Fix stuff the automated generation didn't fix
Make it the first commit to Drupal 9?
Refactor comment form a field to this.

User interface changes

None

API changes

A whole new metadata sub-system that resembles the FieldAPI but can't be configured from the UI.

Follow-up from #731724: Convert comment settings into a field to make them work with CMI and non-node entities.

CommentFileSizeAuthor
metadata.patch683.85 KBlarowlan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

A whole new metadata sub-system that resembles the FieldAPI but can't be configured from the UI.

This is D8's Field API: "base fields" are fields that don't come from the config / admin UI.

$ cp -R core/modules/field core/modules/metadata
$ find core/modules/metadata -type f -exec sed -i "s/field_/metadata_/g;s/Field/Metadata/g" '{}' ';'

Er - uh ?
Start out as two completely separate code bases that provide very similar but slightly different functionnality & behavior ?
Sounds like there are smarter and more maintainable approaches than duplication of a huge code base...

yched’s picture

Looks like all this is about is "fields that do not get loaded upfront whenever the $entity itself is loaded" ?

catch’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update
xjm’s picture

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

Under our continuous upgrade path and deprecation policy, feature and API additions should be added with backwards compatibility in minor releases, so moving to 8.8.x. Thanks!

larowlan’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

This came from a review of the 'comment as field' patch that felt that the 'comment status' of an entity (is it open/locked/hidden) isn't really a field but rather entity-metadata.

But as yched points out, we have base field etc that do this stuff already (published status).

I think this is safe to close