Skip to content

refactor!: replace the slice extension points with typed classes - #6765

Merged
gharlan merged 1 commit into
6.xfrom
handler
Oct 21, 2026
Merged

gharlan merged 1 commit into
6.xfrom
handler

Conversation

@gharlan

@gharlan gharlan commented Oct 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #6762: the extension points dispatched before a slice change become typed classes.

old new carries
SLICE_ADD Content\ExtensionPoint\SliceAdding $article, $contentSectionId, $moduleKey, $revision
SLICE_UPDATE Content\ExtensionPoint\SliceUpdating $slice (before the update)
SLICE_MOVE Content\ExtensionPoint\SliceMoving $slice (before the move), $direction
SLICE_DELETE Content\ExtensionPoint\SliceDeleting $slice
ART_SLICES_COPY Content\ExtensionPoint\ArticleSlicesCopying $article (target), $source, ?int $revision, $overwrite
  • All of them are readonly with a null subject; naming follows the -ing pattern for points dispatched beforehand (like MediaAdding).
  • The slice history listener in boot/core.php is typed with the union of the five classes; the history types stored in the database are unchanged (slice_add, slice_update, slice_moveup/slice_movedown, slice_delete, slices_copy). This drops its psalm baseline entries.
  • Rector rules map Extension::register() calls with the old names.

Fixes along the way

  • ContentHandler::addSlice() did not dispatch SLICE_ADD at all (only the backend page did), so slices added via the API bypassed the slice history. It dispatches SliceAdding now.
  • ArticleSliceHistory::makeSnapshot() required a logged-in user, so with the history enabled every slice change without one (console, cronjobs) failed with a LogicException. It now falls back to the environment name, like the handlers do for createuser/updateuser.

Tests

  • ContentHandlerTest covers the dispatched points and their payloads, including copyContent().
  • New ArticleSliceHistoryTest for a snapshot without a user (fails without the fix).

@gharlan gharlan added this to the REDAXO 6.0 milestone Oct 21, 2026
    SLICE_ADD       -> Content\ExtensionPoint\SliceAdding
    SLICE_UPDATE    -> Content\ExtensionPoint\SliceUpdating
    SLICE_MOVE      -> Content\ExtensionPoint\SliceMoving
    SLICE_DELETE    -> Content\ExtensionPoint\SliceDeleting
    ART_SLICES_COPY -> Content\ExtensionPoint\ArticleSlicesCopying

The points are dispatched before the change and carry the affected slice in its current state, or for adding and
copying the target article together with the content section/module and the source article. They are readonly with a
`null` subject.

`ContentHandler::addSlice()` dispatches `SliceAdding` as well, so slices added via the API end up in the slice
history like those added in the backend. The history no longer requires a logged-in user for the snapshot and falls
back to the environment name, as the handlers do for the create/update user, so slice changes from the console no
longer fail while the history is enabled.
@gharlan
gharlan merged commit 4ee70e7 into 6.x Oct 21, 2026
15 checks passed
@gharlan
gharlan deleted the handler branch October 21, 2026 20:54
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