Skip to content

Commit

Permalink
[BUGFIX] Make slugs unique when copying pages
Browse files Browse the repository at this point in the history
When a page is copied the slug for the copied page
needs to be unique for a site. To accomplish that,
the site for the record is fetched. Since this new
record does not have a uid yet, the parent page uid
must be used to determine the site.

Resolves: #87697
Releases: master, 9.5
Change-Id: Iac5fa7adc673c41662b652e932c23b90633e0d5d
Reviewed-on: https://review.typo3.org/c/59686
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Jürgen Venne <venne@schaffrath-digital.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Jürgen Venne <venne@schaffrath-digital.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
helhum authored and maddy2101 committed Mar 1, 2019
1 parent 87473dc commit 672290f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
8 changes: 7 additions & 1 deletion typo3/sysext/core/Classes/DataHandling/SlugHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,16 @@ public function isUniqueInPid(string $slug, RecordState $state): bool
*/
public function isUniqueInSite(string $slug, RecordState $state): bool
{
$pageId = (int)$state->resolveNodeAggregateIdentifier();
$pageId = $state->resolveNodeAggregateIdentifier();
$recordId = $state->getSubject()->getIdentifier();
$languageId = $state->getContext()->getLanguageId();

if (!MathUtility::canBeInterpretedAsInteger($pageId)) {
// If this is a new page, we use the parent page to resolve the site
$pageId = $state->getNode()->getIdentifier();
}
$pageId = (int)$pageId;

if ($pageId < 0) {
$pageId = $this->resolveLivePageId($recordId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"pages",,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title"
,1,0,256,0,0,0,0,0,0,0,0,0,"FunctionalTest"
,88,1,256,0,0,0,0,0,0,0,0,0,"DataHandlerTest"
,89,88,256,0,0,0,0,0,0,0,0,0,"Relations"
,90,88,512,0,0,0,0,0,0,0,0,0,"Target"
"pages",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l10n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","slug"
,1,0,256,0,0,0,0,0,0,0,0,0,"FunctionalTest","/"
,88,1,256,0,0,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler"
,89,88,256,0,0,0,0,0,0,0,0,0,"Relations","/data-handler/relations"
,90,88,512,0,0,0,0,0,0,0,0,0,"Target","/data-handler/target"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"pages",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title",,,
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest",,,
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest",,,
,89,88,256,0,0,0,0,0,0,0,"Relations",,,
,90,88,512,0,0,0,0,0,0,0,"Target",,,
,91,90,256,0,89,0,0,0,0,0,"Relations",,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","slug",,
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest","/",,
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest","/data-handler",,
,89,88,256,0,0,0,0,0,0,0,"Relations","/data-handler/relations",,
,90,88,512,0,0,0,0,0,0,0,"Target","/data-handler/target",,
,91,90,256,0,89,0,0,0,0,0,"Relations","/data-handler/relations-1",,
"tt_content",,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","header"
,296,88,256,0,0,0,0,0,0,0,0,0,0,"Regular Element #0"
Expand Down

0 comments on commit 672290f

Please sign in to comment.