Skip to content
Snippets Groups Projects

[BUGFIX] Properly setup AbstractSitemapGenerator construction

Merged Matthias Adrowski requested to merge bugfix_pageid_0 into master
All threads resolved!
1 file
+ 26
6
Compare changes
  • Side-by-side
  • Inline
@@ -44,11 +44,31 @@ class GoogleSitemapController extends ActionController {
$sitemapType = $this->getSitemapType();
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sg_seo']['sitemap'][$sitemapType])) {
$userFuncRef = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sg_seo']['sitemap'][$sitemapType];
$params = array();
GeneralUtility::callUserFunction($userFuncRef, $params, $this);
}
else {
header('HTTP/1.0 400 Bad request', true, 400);
$params = [];
// since our AbstractSitemapGenerator will need specific details in its __construct,
// we need to be in charge of makeInstance.
// This code is taken from GeneralUtility::callUserFunction
$parts = explode('->', $userFuncRef);
// Create object
// ARGS: int $pageId = 0, SiteLanguage $language = NULL, bool $enableFilter = TRUE
$abstractSitemapGeneratorArgs = [
$GLOBALS['TSFE']->id,
$GLOBALS['TSFE']->language,
TRUE
];
$classObj = GeneralUtility::makeInstance($parts[0], ...$abstractSitemapGeneratorArgs);
$callable = [$classObj, (string) $parts[1]];
if (is_callable($callable)) {
// Call method:
call_user_func_array($callable, [&$params, &$ref]);
} else {
$errorMsg = 'No method name \'' . $parts[1] . '\' in class ' . $parts[0];
throw new \InvalidArgumentException($errorMsg, 1294585865);
}
} else {
header('HTTP/1.0 400 Bad request', TRUE, 400);
header('Content-type: text/plain');
echo 'No generator found for type \'' . $sitemapType . '\'';
}
@@ -59,7 +79,7 @@ class GoogleSitemapController extends ActionController {
/**
* Determines what sitemap should be send
*
* @return string
* @return string
*/
protected function getSitemapType(): string {
$type = GeneralUtility::_GP('sitemap');
Loading