Project

General

Profile

Actions

Bug #95072

closed

Custom aspect leads to list view on hidden elements

Added by Stephan Bauer about 3 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2021-09-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:
On Location Sprint

Description

I made a custom aspect for EXT:news for categories.
Everything works as expected but there is a problem with hidden elements or wrong links.

Instead of the error page with the http status 404 the site shows the list view or a server error
(1/1) Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "xxx" for route "tx_news_pi1_1" must match ".+" ("" given) to generate a corresponding URL.

I also made an mini extension to see if this is a EXT:news problem but the problem occurs there also.

I tried to separate list and show and tested 'limitToPages' with no luck.

The EXT is attached and this is my yaml config:

  Test:
    type: Extbase
    extension: Test
    plugin: Test
    routes:
      -
        routePath: '/{title}'
        _controller: 'Test::show'
        _arguments:
          title: test
      -
        routePath: /
        _controller: 'Test::list'
      -
        routePath: '/{categoryName}'
        _controller: 'Test::list'
        _arguments:
          categoryName: overwriteDemand/categories
    defaultController: 'Test::list'
    aspects:
      title:
        type: PersistedAliasMapper
        tableName: tx_test_domain_model_test
        routeFieldName: slug
      categoryName:
        type: CategoriesValueMapper

Files

test_1.0.0_202109012329.zip (20.2 KB) test_1.0.0_202109012329.zip Test extension Stephan Bauer, 2021-09-01 21:29
clipboard-202109151627-kkb3v.png (23.2 KB) clipboard-202109151627-kkb3v.png Stephan Bauer, 2021-09-15 14:27
clipboard-202109151627-zofzw.png (22.3 KB) clipboard-202109151627-zofzw.png Stephan Bauer, 2021-09-15 14:27

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #94585: Siteconfig - 404 error not triggered if routeEnhancers is configuredClosed2021-07-19

Actions

Updated by Stephan Bauer about 3 years ago

On a test installation it shows the same problem a mentioned in #94585

Deaktivated Element:

Actions #2

Updated by Stephan Bauer about 3 years ago

  • Related to Bug #94585: Siteconfig - 404 error not triggered if routeEnhancers is configured added
Actions #3

Updated by Oliver Hader about 2 years ago

  • Assignee set to Oliver Hader
  • Sprint Focus set to On Location Sprint
Actions #4

Updated by Oliver Hader about 2 years ago

I've just analyzed the provided CategoriesValuesMapper and found the problem there. URL that cannot be resolved need to return null, in that mapper example, the return value is always a string (which might be empty).

   public function resolve(string $value): ?string
    {
        //DebuggerUtility::var_dump($value, 'resolve');
        $categorieIDsArray = explode('_',$value);
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category');
        $categories = $queryBuilder->select('uid', 'slug')
            ->from('sys_category')
            ->where(
                $queryBuilder->expr()->in('slug', $queryBuilder->createNamedParameter($categorieIDsArray, Connection::PARAM_STR_ARRAY)),
            )
            ->orderBy('parent')
            ->execute()
            ->fetchAll();
        $routing = strval($categories[0]['uid']);
### -> ###         ^^ that's the problem, `$routing` is always as string
        if($categories[1]) {
            $routing .= "," . strval($categories[1]['uid']);
        }

        if (isset($routing)) {
            return (string)$routing;
        }
        return null;
    }

Potential modification to return null when having mismatches (and have 404 handling working):

   public function resolve(string $value): ?string
    {
        //DebuggerUtility::var_dump($value, 'resolve');
        $categorieIDsArray = explode('_',$value);
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category');
        $categories = $queryBuilder
            /* ... */
            ->fetchAll();

        // no category could be resolved, return `null`, triggers 404 handling
        if (!isset($categories[0]['uid'])) {
            return null;
        }

        $routing = $categories[0]['uid'];
        if (isset($categories[1]['uid])) {
            $routing .= "," . strval($categories[1]['uid']);
        }

        return $routing;
    }
Actions #5

Updated by Oliver Hader about 2 years ago

  • Status changed from New to Closed

Adjusting the custom aspect mapper to return null for mismatches resolved the problem. I'm closing this issue. Please feel free to reopen, in case you think that there's still something in the TYPO3 core that needs to be changed. Thx!

Actions #6

Updated by Stephan Bauer over 1 year ago

Thank you, it was my fault.

Actions

Also available in: Atom PDF