Bug #94701
closedDashboard breaks if Guzzle Middleware is used
0%
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
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
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.
Updated by David Bruchmann over 3 years ago
- File guzzle_test.zip guzzle_test.zip added
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
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
- File clipboard-202108060641-nzqih.png clipboard-202108060641-nzqih.png added
- File clipboard-202108060646-wysdu.png clipboard-202108060646-wysdu.png added
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:
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.
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.
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
Updated by Benni Mack over 3 years ago
- Related to Bug #94015: GeneralUtility::xml2array() can't be used in Guzzle middleware added