Skip to content

refactor!: integrate the meta fields directly into the content, media pool and language forms - #6778

Merged
gharlan merged 5 commits into
6.xfrom
metainfo
Oct 21, 2026
Merged

gharlan merged 5 commits into
6.xfrom
metainfo

Conversation

@gharlan

@gharlan gharlan commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Meta info is part of the core now, so it no longer needs to hook into the forms and save routines of categories, articles, media and languages via extension points.

Changes

  • The add()/edit() methods of CategoryHandler, ArticleHandler, MediaHandler and LanguageHandler (ArticleHandler::add() included, although the backend form for adding articles has no meta fields) take an optional array $meta, keyed by the storage key of the field (the column without the meta_ prefix), each value of the property type. Only the given values are saved, so they can also be called with explicit values, e.g. by addons or the project:
    CategoryHandler::edit($id, $languageId, [], meta: ['seo_title' => 'Über uns']);
    The new internal MetaInfo\MetaValues converts them into the column values and rejects unknown keys and values not matching the property type before anything is written. The handlers save the values within their own insert/update statements.
  • New MetaInfo\MetaForm holds the meta fields of an item in the backend forms (submit(), hasErrors(), render(), values()). It replaces the classes in MetaInfo\Handler\*. The pages and api functions validate the submitted values before saving the item and pass $metaForm->values() to the handler.
  • Invalid meta values no longer leave an item saved without its meta values (previously the listener of CategoryAdded etc. threw after the item had been saved). Now nothing is saved, and the form is shown again with the submitted values and the errors at the fields. The category form stays open for this, and the meta row of categories and languages expands.
  • boot/backend.php no longer registers meta info listeners. The article meta sidebar is included directly by content.php.
  • The meta check of MediaPool::mediaIsInUse() moves to MetaInfo\MediaUsage and is called directly.
  • ART_META_UPDATED is removed: the sidebar saves via ArticleHandler::edit(), which dispatches ArticleUpdated (rector rule added).
  • ArticleHandler::edit() keeps the template if the template key is missing (previously it fell back to the first allowed template).
  • MediaHandler::edit() writes the translation only after the file checks.
  • The lang key minfo_metadata_not_saved becomes minfo_metadata_invalid. The rector class mappings rex_metainfo_*_handler are removed, as their target classes are gone.

The form extension points (CAT_FORM_*, MEDIA_FORM_*, LanguageForm*, STRUCTURE_CONTENT_SIDEBAR, MEDIA_IS_IN_USE) stay available for addons.

Testing

MetaValuesTest and a MediaHandlerTest case cover the array API, including partial updates.

Tested in the browser with temporary meta schemas (a shared field with maxLength plus a required translated field per entity): adding and editing languages and categories, the article sidebar, and media upload and edit, each first with invalid and then with valid values.

… pool and language forms

Meta info is part of the core, so it no longer hooks into the forms and
save routines via extension points. The new `MetaForm` holds the meta
fields of an item: the pages and api functions validate the submitted
values before saving the item and pass the form to the `add()`/`edit()`
methods of `CategoryHandler`, `ArticleHandler`, `MediaHandler` and
`LanguageHandler`, which write the values within their own statements.

Invalid meta values therefore no longer leave an item saved without
them. Nothing is saved, the form is shown again with the submitted
values and the errors at the fields; the category form stays open for
this.

The handler classes in `MetaInfo\Handler` are removed. The meta check of
`MediaPool::mediaIsInUse()` moves to `MetaInfo\MediaUsage` and is called
directly. The article meta sidebar saves via `ArticleHandler::edit()`, so
`ART_META_UPDATED` is replaced by `ArticleUpdated`. `ArticleHandler::edit()`
keeps the template if `template` is not passed.

The form extension points (`CAT_FORM_*`, `MEDIA_FORM_*`, `LanguageForm*`,
`STRUCTURE_CONTENT_SIDEBAR`, `MEDIA_IS_IN_USE`) stay available for addons.
@gharlan gharlan added this to the REDAXO 6.0 milestone Oct 21, 2026
The add()/edit() methods of the category, article, media and language
handlers take the meta values as plain array keyed by the storage key of
the field, instead of the MetaForm, so they can be called with explicit
values, e.g. by addons or the project. Only the given values are saved.

The new MetaValues converts them into the column values and rejects
unknown keys and values not matching the property type, before anything
is written. MetaForm::values() returns the submitted values for the
backend pages.
@gharlan
gharlan merged commit 2fa1b37 into 6.x Oct 21, 2026
16 checks passed
@gharlan
gharlan deleted the metainfo branch October 21, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants