Skip to content

feat!: report the usages of media, media categories and articles via typed extension points - #6780

Merged
gharlan merged 1 commit into
6.xfrom
usage-check
Oct 21, 2026
Merged

gharlan merged 1 commit into
6.xfrom
usage-check

Conversation

@gharlan

@gharlan gharlan commented Oct 21, 2026

Copy link
Copy Markdown
Member

The in-use checks of media and media categories become typed extension points, and articles get the same check, so addons can block the deletion of an article they still reference (e.g. YForm relations).

Changes

  • New Util\UsageList: extensions add usages via add($group, $label, ?$url) (all plain text); the core renders and escapes the list in one place. Extensions no longer build HTML snippets.
  • Extension points (readonly, carrying the item and $usages):
    • MEDIA_IS_IN_USE → MediaPool\ExtensionPoint\MediaUsageCheck
    • MEDIA_CATEGORY_IS_IN_USE → MediaPool\ExtensionPoint\MediaCategoryUsageCheck
    • new: Content\ExtensionPoint\ArticleUsageCheck
  • MediaPool::mediaIsInUse() and MediaCategoryHandler::isInUse() are replaced by findUsages() returning the UsageList; ArticleHandler::findUsages() is added. The rector mappings to the old methods are removed, since the signatures changed.
  • Meta info: MetaInfo\MediaUsage becomes MetaInfo\MetaUsage with addMediaUsages() and addArticleUsages(), called directly (no extension point). Articles referenced in article picker meta fields can no longer be deleted; the article itself and the category it is the start article of are skipped.
  • Deleting a referenced article shows the grouped usage list with links (like the media pool) instead of a plain list of names.
  • Usage links are plain links now. openPage() only works in the media pool popup, so mediapool.js redirects usage links leading out of the media pool to the main window only there.
  • Lang keys: minfo_media_in_use_* → minfo_usage_*, pool_file_in_use_articles → usage_articles_content.

Testing

  • Unit tests for the rendering/escaping of UsageList and for an extension blocking the deletion via ArticleUsageCheck.
  • In the browser with a temporary meta schema (article picker + media picker on articles): deleting an article referenced in the meta fields fails with the usage list, an article referencing itself can be deleted, deleting a referenced medium in the media pool popup shows the list, and its link opens the article in the main window and closes the popup.

…typed extension points

The usage checks collect their findings in a `UsageList` (group, label, url as plain text), which renders the list
centrally, instead of extensions building and escaping HTML snippets themselves.

MEDIA_IS_IN_USE          -> MediaPool\ExtensionPoint\MediaUsageCheck
MEDIA_CATEGORY_IS_IN_USE -> MediaPool\ExtensionPoint\MediaCategoryUsageCheck
(new)                    -> Content\ExtensionPoint\ArticleUsageCheck

`MediaPool::mediaIsInUse()` and `MediaCategoryHandler::isInUse()` are replaced by `findUsages()`, which return the
`UsageList`; `ArticleHandler::findUsages()` is added. Deleting an article now also checks the article picker meta
fields (skipping the article itself and its category) and lists the usages like the media pool does.

Usage links are plain links now; in the media pool popup, links leading out of the media pool open in the main window.
@gharlan gharlan added this to the REDAXO 6.0 milestone Oct 21, 2026
@rex-bot rex-bot added breaking feature Additional functionality labels Oct 21, 2026
@gharlan
gharlan merged commit cde838e into 6.x Oct 21, 2026
15 checks passed
@gharlan
gharlan deleted the usage-check branch October 21, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking feature Additional functionality

Development

Successfully merging this pull request may close these issues.

2 participants