Project

General

Profile

Actions

Bug #94701

closed

Dashboard breaks if Guzzle Middleware is used

Added by David Bruchmann over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-08-03
Due date:
% Done:

0%

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

Description

If a Guzzle Middleware is used the Dashboard modules "TYPO3 news" and "TYPO3 security advisories" do not work anymore.

Related to that might be that $GLOBALS['TYPO3_CONF_VARS']['HTTP']['handler'] is handled somehow strange, the values are not visible always and in the backend Configuration Module it looks always empty.


Files

guzzle_test.zip (3.08 KB) guzzle_test.zip Test Extension for #94701 David Bruchmann, 2021-08-03 19:02
clipboard-202108060641-nzqih.png (155 KB) clipboard-202108060641-nzqih.png David Bruchmann, 2021-08-05 23:42
clipboard-202108060646-wysdu.png (67.9 KB) clipboard-202108060646-wysdu.png David Bruchmann, 2021-08-05 23:46

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #94015: GeneralUtility::xml2array() can't be used in Guzzle middlewareClosed2021-04-29

Actions
Actions #1

Updated by David Bruchmann over 3 years ago

This error is logged:

Core: Exception handler (WEB): Uncaught TYPO3 Exception:
Argument 1 passed to GuzzleHttp\HandlerStack::push() must be callable, null given,
called in /var/www/html/public_html/typo3/sysext/core/Classes/Http/Client/GuzzleClientFactory.php on line 55 | TypeError thrown
in file /var/www/html/typo3app/vendor/guzzlehttp/guzzle/src/HandlerStack.php in line 143.
Requested URL: http://127.0.0.1:51361/typo3/index.php?route=%%2Fajax%%2Fdashboard%%2Fwidget%%2Fcontent&token=--AnonymizedToken--&widget=t3securityAdvisories

Actions #2

Updated by Benni Mack over 3 years ago

  • Status changed from New to Needs Feedback

Hey David,

can you give a few more details?

a) Do you push a middleware from which Guzzle package to TYPO3's middleware stack?
b) Or are you using a custom handler for TYPO3_CONF_VARS[HTTP]?

Can you give me a few steps on how to reproduce your issue?

thanks in advance,
benni.

Actions #3

Updated by David Bruchmann over 3 years ago

Hi Benni,

thanks for the quick answer.

The attached extension can be installed to reproduce the issue, it's limited to the most important settings.

I use ext_localconf.php to add the Handler to $GLOBALS['TYPO3_CONF_VARS']['HTTP']['handler'], so I don't "push a middleware from which Guzzle package to TYPO3's middleware stack".

Dependency injection like shown in the manual doesn't work, but I think in my example it's not relevant.
https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/ApiOverview/Http/Index.html

Actions #4

Updated by Benni Mack over 3 years ago

  • Project changed from 9 to TYPO3 Core
  • TYPO3 Version set to 10

Updated by David Bruchmann over 3 years ago

With activated Guzzle-Middleware the Variable $GLOBALS['TYPO3_CONF_VARS']['HTTP']['handler'] has one empty value only:

The debug-output is done here: TYPO3\CMS\Core\Http\Client\GuzzleClientFactory::getClient:38 before the hook.

Without Guzzle-Middleware the handler-stack has 4 handlers:

Actions #6

Updated by David Bruchmann over 3 years ago

I remarked that my usage in the provided extension is not complete and the method handle has to return a callable.

The examples on https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Http/Index.html are working as simple hook but never fulfill the requirements for a guzzle-middleware. Therefore the hook fails in a stack of working middlewares.
Further info: https://docs.guzzlephp.org/en/latest/handlers-and-middleware.html#handlers

While the linked TYPO3-documentation can be regarded as completely misleading and wrong the requirement fore a simple hook does exist and is quite useful.
My combination of the examples of the linked TYPO3-documentation is wrong, nevertheless the requirement for a simple hook does exist and is quite useful, btw. it's used in production already and I've another production candidate for the hook.

As painful as it is for me: the issue can be closed.

Actions #7

Updated by Benni Mack over 3 years ago

  • Status changed from Needs Feedback to Closed

Thanks for the feedback and sharing all the details. I'm sure people will get back to this issue and find this information from you helpful.

Actions #8

Updated by David Bruchmann over 3 years ago

Thanks for the answer, I ended up with a simple PSR-15 middleware which is easier and sufficient and also not bound to Guzzle which wouldn't be so logical.
https://docs.typo3.org/m/typo3/reference-coreapi/9.5/en-us/ApiOverview/RequestHandling/Index.html

Actions #9

Updated by Benni Mack over 3 years ago

  • Related to Bug #94015: GeneralUtility::xml2array() can't be used in Guzzle middleware added
Actions

Also available in: Atom PDF