FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
189 stars 228 forks source link

BUG: When VHS is installed using redirect in controller does not work without extensionName argument #1892

Closed fnagel closed 8 months ago

fnagel commented 10 months ago

I have checked that the bug exists in the dev-development branch No, as there are only two minor commits (be65ecd87e092ff5cde97f5c7a93ec3adbd232bb and 18866ba4f609ae6a8840eca7c658c601b1339647) since the 7.0.1 release.

I have checked that there are no already open issues or recently closed issues about this bug Yes, there are tickets that might be related: #1885 and #1673

Describe the bug When VHS is installed using redirect() in controller does not work without extensionName argument. Installation is enough, no need to actual use ANY view helper for EXT:vhs.

To Reproduce Steps to reproduce the behavior:

Expected behavior The response URI should always be valid, like: https://www.felixnagel.docker/blog/artikel/2023/12/01/typo3-v12-test/

Additional context Tested with TYPO3 v12.4.8 and VHS v7.0.1 Tested in an introduction package instance without VHS too. No issues there.

NamelessCoder commented 10 months ago

Can you check if disabling the asset feature in extension configuration (option disableAssetHandling), or commenting out the single active line of code in \FluidTYPO3\Vhs\Middleware\RequestAvailability makes a difference? These are the only two things I can think of that could have an effect if no ViewHelpers are used.

fnagel commented 10 months ago

Checked option disableAssetHandling and class RequestAvailability but the issue is still there :-/

NamelessCoder commented 8 months ago

I can't reproduce this problem. I get the exact same URL and behavior with and without VHS installed. Tested with EXT:news and EXT:blog, same situation for both...

From the URLs it looks like the UriBuilder is incapable of reading the pluginName from $this->extensionService->getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action'] ?? null); and $this->request->getPluginName(); (extension name would come from $extensionName = $this->request->getControllerExtensionName();). The first call to getPluginNameByAction probably returns an empty value.

It might help give me a hint about what's happening if you can debug the Request assigned to UriBuilder and see how it differs when VHS is installed / not installed. Catching it in \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::setRequest is probably best. It would also be interesting to see if the call stack is different in those cases.

einpraegsam commented 8 months ago

Seems to be the same problem that I just described here: https://forge.typo3.org/issues/102929 When VHS 7.0.1 is installed, f:form.action and f:uri.link are also without pluginName or extensionName

VHS 7.0.0 works because this change breaks the request in Services.yaml:

  TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder:
    autowire: true
    public: true
NamelessCoder commented 8 months ago

@einpraegsam Can you check for me if adding shared: false to that service definition would fix the problem?

einpraegsam commented 8 months ago

Yes, you are right @NamelessCoder - this fixes the problem:

    TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder:
      autowire: true
      public: true
      shared: false
NamelessCoder commented 8 months ago

Awesome! Let's get that included and released asap.

NamelessCoder commented 8 months ago

VHS 7.0.2 is now released and includes this fix. Thanks for the perfect hint @einpraegsam - instance reuse perfectly explains why this happened and I didn't consider that this could be the problem until that.

einpraegsam commented 8 months ago

Great performance - thx!

fnagel commented 8 months ago

Thanks for digging into it @einpraegsam! And for the fast release @NamelessCoder!

I can confirm the fix for my extension!

The change to the UriBuilder service configuration was introduced here https://github.com/FluidTYPO3/vhs/commit/4af29f6fbecc4fb469990e7aa27253e1494fc4e4#diff-d2a9a6effbda1d2c980f54b0f322f984996372c98b3af0577b8ec747d467735c so this is an issue in version 7.0.0-7.0.1, right?

NamelessCoder commented 8 months ago

Yep, this one affects both 7.0.0 and 7.0.1