Skip to content
Snippets Groups Projects
Commit 0113c543 authored by Stefan Bürk's avatar Stefan Bürk Committed by Stefan B�rk
Browse files

[TASK] Use later DataHandler hook in `DataHandlerSlugUpdateHook`

Handling the pages slug changed event has been implemented with
a dedicated hook handling class, consuming two DataHandler hooks
to prepare and handle the redirect creation and slug update for
subpages. Auto redirect creation and subpage slug updating are
controlled by site setting configuration options.

The chosen second hook `processDatamap_postProcessFieldArray()`
is executed before the record is persisted into the database.

This change switches to `processDatamap_afterDatabaseOperations()`
as the second hook, so handling code can expect to have the
changes persisted to the database already. For example, this
would allow to use the slug generator in the `updateSlug()`
method in a dedicated change as possible solution for #96928.

Resolves: #101335
Related: #96928
Releases: main, 12.4
Change-Id: I5a83b6ecb9bebd7d1ebf1f3c704ca2ec2c10aa96
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80010


Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarStefan B�rk <stefan@buerk.tech>
Tested-by: default avatarStefan B�rk <stefan@buerk.tech>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 01231869
Branches
Tags
No related merge requests found
......@@ -68,10 +68,10 @@ class DataHandlerSlugUpdateHook
/**
* Acts on potential slug changes.
*
* Hook `processDatamap_postProcessFieldArray` is executed after `DataHandler::fillInFields` which
* ensure access to pages.slug field and applies possible evaluations (`eval => 'trim,...`).
* Hook `processDatamap_afterDatabaseOperations` is a record has been persisted and after `DataHandler::fillInFields`
* which ensure access to `pages.slug` field and applies possible evaluations (`eval => 'trim,...`).
*/
public function processDatamap_postProcessFieldArray(string $status, string $table, $id, array $fieldArray, DataHandler $dataHandler): void
public function processDatamap_afterDatabaseOperations(string $status, string $table, $id, array $fieldArray, DataHandler $dataHandler): void
{
$persistedChangedItem = $this->persistedChangedItems[(int)$id] ?? null;
......@@ -85,7 +85,7 @@ class DataHandlerSlugUpdateHook
) {
return;
}
// We need to merge the current changed to the retrieved record, because they are not persisted yet.
// We merge the fieldArray dataset into with the original record to spare a database query here.
$persistedChangedItem = $persistedChangedItem->withChanged(array_merge($persistedChangedItem->getOriginal(), $fieldArray));
$this->slugService->rebuildSlugsForSlugChange($id, $persistedChangedItem, $dataHandler->getCorrelationId());
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment