Feature #89862
closedProvide the current's record uid in SlugHelper and the postModifiers hook
100%
Description
When using the SlugHelper
postModifiers hook it would be useful to also have the current record uid in the parameters.
For example when building slugs for Extbase records you probably need to select the full row or irows of related records to retrieve relevant information from the entity. This is not possible when there's no uid provided.
The generate()
method does not get the record uid passed and thus can not pass it to the hooks. But it seems the id is always available whenever the SlugHelper::generate()
method is called by the core.
Updated by Oliver Bartsch almost 5 years ago
- Status changed from New to Needs Feedback
- Assignee deleted (
Oliver Bartsch)
I made several tests on this issue. What I can say is that for me in latest v10 and latest v9 the records array contains the correct record uid as soon as the record is persisted.
Only on newly unsafed records there is no uid just the NEW... string which won't help really much for fetching relations IMO.
Here is some output of my tests with v10:
One creates a new record and DOESN'T FILL a generator field. Than clicks save (saving the record).
Output: No uid in records array
generator function call: DataHandler::checkValueForSlug (Line:1852)
$value = $helper->generate($fullRecord, $realPid, $id);
One creates a new record and FILLS OUT a generator field. Than clicks save (saving the record).
Output: No uid in records array
generator function call: DataHandler::checkValueForSlug (Line:1852)
$value = $helper->generate($fullRecord, $realPid, $id);
One creates a new record and DOESN'T FILL a generator field. Than clicks on the "suggest" button of the slug element.
Output: No uid in records array
generator function call: FormSlugAjaxController::suggestAction (Line:99)
elseif ($mode === 'recreate') {
$proposal = $slug->generate($recordData, $parentPageId, $recordId);
}
One creates a new record and FILLS OUT a generator field. Than clicks on the "suggest" button of the slug element.
Output: No uid in records array
generator function call: FormSlugAjaxController::suggestAction (Line:99)
elseif ($mode === 'recreate') {
$proposal = $slug->generate($recordData, $parentPageId, $recordId);
}
One has already persisted a record, removes the slug manually and than clicks save (saving the record).
Output: Uid is present in records array
generator function call: DataHandler::checkValueForSlug (Line:1852)
$value = $helper->generate($fullRecord, $realPid, $id);
One has already persisted a record and than clicks on the "suggest" button of the slug element.
Output: Uid is present in records array
generator function call: FormSlugAjaxController::suggestAction (Line:99)
in /var/www/html/typo3/sysext/backend/Classes/Controller/FormSlugAjaxController.php line 99
elseif ($mode === 'recreate') {
$proposal = $slug->generate($recordData, $parentPageId, $recordId);
}
One has already persisted a record, changes a generator fields value and than clicks on the "suggest" button of the slug element.
Output: Uid is present in records array
generator function call:FormSlugAjaxController::suggestAction (Line:99)
elseif ($mode === 'recreate') {
$proposal = $slug->generate($recordData, $parentPageId, $recordId);
}
I don't think we should extend the hook just to provide the NEW... string. What do you think?
Updated by S P almost 5 years ago
- Priority changed from Should have to Must have
On 9.5.11 if you click on the "rotating arrow" button next to a TCA type slug field in an already persisted record, the record data does not contain the uid of the record (I checked for a custom extbase table).
You are right about new records. But for new records we should have the full record in the hook anyways (including the fields that hold uids to related records).
Currently the hook is basically useless. How should the hook modify the slug if there's no relevant information provided at all that could be used to modify the slug? What is the hook for, then, what's its intended purpose?
Updated by Gerrit Code Review over 4 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63447
Updated by Gerrit Code Review over 4 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63455
Updated by Susanne Moog over 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9751097b3abc49e921da4f5ff5ba26f8cb33353c.