Project

General

Profile

Actions

Feature #89862

closed

Provide the current's record uid in SlugHelper and the postModifiers hook

Added by Stefan P over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2019-12-05
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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.

Actions #1

Updated by Oliver Bartsch over 4 years ago

  • Assignee set to Oliver Bartsch
Actions #2

Updated by Oliver Bartsch over 4 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?

Actions #3

Updated by Stefan P over 4 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?

Actions #4

Updated by Gerrit Code Review about 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

Actions #5

Updated by Gerrit Code Review about 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

Actions #6

Updated by Susanne Moog about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF