Project

General

Profile

Actions

Bug #87730

closed

Route Enhancers/Aspects: StaticRangeMappers make PersistedAliasMapper be ignored

Added by Hagen Gebauer almost 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2019-02-18
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
On Location Sprint

Description

I have a route enhancer setting for two extensions that need both date (yyyy/mm/dd) and a title based path_segment in the URL, one of them being tx_news:

requirements:
year: '^20[0-9]{2}$'
month: '^[01][0-9]$'
day: '^[0-3][0-9]$'
aspects:
year:
type: StaticRangeMapper
start: '2016'
end: '2030'
month:
type: StaticRangeMapper
start: '01'
end: '12'
day:
type: StaticRangeMapper
start: '01'
end: '31'
news:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'

The requirements alone – without the StaticRangeMappers – do not make the cHash in the link disappear (although according to the description only loose requirements should do so – I do not consider those requirements regex loose). However, adding the StaticRangeMappers for year/month/day does remove the cHash (and the requirements aren’t needed anymore) but the PersistedAliasMapper will then be ignored and the record UID will be attached to the URL instead. Calling that link will result in a 404.

Additionally I sometimes got the following TYPO3 exception: (1/1) #1537696772 OverflowException: Possible range of all mappers is larger than 10000 items. – which seems a bit odd considering the given range.

There is a stackoverflow thread on that, too:
https://stackoverflow.com/questions/54669488/typo3-9-add-date-to-url-routing-enhancers-for-news-extension


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #90123: Avoid applying zero prefix for zero in StaticRangeMapperClosed2020-01-15

Actions
Actions #1

Updated by Rene Tobias over 5 years ago

I have the same problem. But i think there's only a problem with months that starts with 0. So like januar (01), februar (02). If i change date to december (12) it works normally.

Can you test that?

Actions #2

Updated by Gerrit Code Review over 5 years ago

  • Status changed from New 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/+/59837

Actions #3

Updated by Gerrit Code Review over 5 years ago

Patch set 2 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/+/59837

Actions #4

Updated by Jo Hasenau over 5 years ago

  • Status changed from Under Review to New

Sorry for the wrong issue number in my patch. It was meant to be #87830

Actions #5

Updated by Hagen Gebauer over 5 years ago

Rene Tobias Tobias wrote:

I have the same problem. But i think there's only a problem with months that starts with 0. So like januar (01), februar (02). If i change date to december (12) it works normally.

Thanks for the note which I can confirm – for both days and months: the `PersistedAliasMapper`works with the date set to 10th of October (2019/10/10) whereas it won’t for 9th of October (2019/10/09) or 10th of September (2010/09/10).

Actions #6

Updated by Hagen Gebauer about 5 years ago

There is a solution on the above mentioned Stack Overflow thread: https://stackoverflow.com/a/57523969/4274248
The reason for the behaviour is that the StaticRangeMapper converts the values to integer values and thus they lose their leading zeros. So it might work as originally tried without leading zeros or you write your own mappers as suggested in the solution on Stack Overflow.

Actions #7

Updated by Oliver Hader almost 5 years ago

  • Status changed from New to Accepted

Thanks for the description and the hint on values starting with zero (0) which is indeed the problem here.
StaticRangeMapper is using internally PHP's range function.

For the date values from 01 to 12 the code would look like this:

var_dump(range('01', '12'));

array(12) {
  [0] => int(1)
  [1] => int(2)
  [2] => int(3)
  [3] => int(4)
  [4] => int(5)
  ...
  [9] => int(10)
  [10] => int(11)
  [11] => int(12)
}

Thus, the leading zero is removed from the internal map - 1 would be accepted, but 01 not.

Actions #8

Updated by Oliver Hader almost 5 years ago

As a work-around StaticValueMapper could be used to defined those values.
In any way, the range issue is a bug in StaticRangeMapper.

Actions #9

Updated by Gerrit Code Review almost 5 years ago

  • Status changed from Accepted 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/+/62864

Actions #10

Updated by Oliver Hader almost 5 years ago

  • Sprint Focus set to On Location Sprint
Actions #11

Updated by Gerrit Code Review almost 5 years ago

Patch set 2 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/+/62864

Actions #12

Updated by Gerrit Code Review almost 5 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/+/62893

Actions #13

Updated by Oliver Hader almost 5 years ago

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

Updated by Oliver Hader almost 5 years ago

  • Related to Bug #90123: Avoid applying zero prefix for zero in StaticRangeMapper added
Actions #15

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF