RouteEnhancer with aspects throws InvalidParameterException
Asked Answered
F

2

5

I used the example verbatim from the Changelog:

The only thing I changed was the limitToPages.

routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages: [82]
    extension: News
    plugin: Pi1
    routes:
      - { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
    defaultController: 'News::detail'
    aspects:
      news_title:
        type: PersistedAliasMapper
        tableName: 'tx_news_domain_model_news'
        routeFieldName: 'path_segment'
        routeValuePrefix: '/'

This throws an exception in 9.5.4:

Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match "[^/]++" ("" given) to generate a corresponding URL.

in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 155


at Symfony\Component\Routing\Generator\UrlGenerator->doGenerate(array('tx_news_pi1__news' => 0), array('_controller' => 'News::detail'), array(), array(array('variable', '/', '[^/]++', 'tx_news_pi1__news', true), array('text', '/aktuelles/artikel')), array('tx_news_pi1__news' => ''), 'tx_news_pi1_0', 1, array(), array())
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 128

Currently, no other route enhancers exist. But I successfully used a simpler configuration on that exact same page and that worked:

NewsDetail:
  type: Extbase
  limitToPages: [82]
  extension: News
  plugin: Pi1
  routes:
    - { routePath: '/{news_id}', _controller: 'News::detail', _arguments: {'news_id': 'news'} }

Not sure where to look and how best to troubleshoot. I was hoping someone had similar problem or could point me in the right direction.

Fret answered 1/3, 2019 at 16:5 Comment(10)
I did seen this error before. Ensure your news entries have slug filled with valid values. Se DB tx_news_domain_model.path_segment. If not, there is an Installtool Upgrade Wizard.Idiotic
Thanks. That was the problem. I did use the Upgrade Wizard. Some of these entries were not converted. Only a handful. The rest looks ok. Not sure why. If path_segment is set to some value, the exception disappears.Fret
...entries were not converted... Upgrade wizard should work for all news entries, where path_segement is empty. Does those of your failed entries have a valid title? Otherwise we should investigate, why convertion failed.Idiotic
I'll check it out ... will be back with more info.Fret
tx_news_domain_model_news.path_segment already exists in original TYPO3 8 instance of which a clone was used to update to TYPO3 9. Here, some of the entries (67 of over 2000) have an empty path_segement. Of these, 17 have empty title. For the other the title is filled. So this is an "older" issue and I am not sure if it is worth the effort to track it down.Fret
Marking "Updates slug field "path_segment" of EXT:news records" of news extension" wizard as done and running it again throws exception: "No valid wizard identifier given".Fret
I mean, there is currently an issue with UpgradeWizard identifiers, in TYPO3 9. But did not found any solution yet. Its even more invalid, if you use typo3_console at the moment. You can edit manually in DB - to solve this temporarlyIdiotic
Can you add a link?Fret
github.com/TYPO3-Console/TYPO3-Console/issues/… review.typo3.org/c/Packages/TYPO3.CMS/+/58197Idiotic
@jokumer. Thanks for your help. I am not sure this is the same problem. Shouldn't this be fixed in 9.5.5? Just came out. the sys_registry contains class names only. I am starting a new question on this because it is related but handling this in comments probably not the best idea. #55026474Fret
F
7

Check if empty path_segment is the problem here:

select count(*) from tx_news_domain_model_news where path_segment='';

Fix

If there are news entry with empty titles, you may want to remove these or update the title first.

  • Run update wizard: "Updates slug field "path_segment" of EXT:news records" (you may have to mark it as "undone" in Upgrade Wizard first (BE: Upgrade > Upgrade Wizard > Run Upgrade Wizard)
  • Or manually set tx_news_domain_model_news.path_segment
Fret answered 1/3, 2019 at 16:5 Comment(1)
The missing value for "path_segment" can happen if an editor doesn't have permissions on that field. The permissions to that exclude field has to be granted otherwise the value will be "" if an editor creates a new news entry.Triglyceride
C
1

Same problem for me, the problem was because 'path_segment' generated with Install Tool Wizard had a slash, like : "the-path/another-segment"

The solution is to check for slash in 'path_segment' and replace them with another symbol, request like this :

SELECT uid, pid, path_segment, title FROM tx_news_domain_model_news WHERE path_segment LIKE "%/%";

and change path_segment like that : "the-path_another-segment"

Cosenza answered 14/2, 2020 at 9:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.