Yoast / Yoast-SEO-for-TYPO3

Yoast SEO plugin for TYPO3
Other
51 stars 56 forks source link

[BUG] Exceptions in BackEnd Illegal string offset 'tx_yoastseo_dont_use' PageMetaRenderer.php line 30 #213

Closed dkd-kaehm closed 5 years ago

dkd-kaehm commented 6 years ago

By using of modules on different extensions I get exception "Illegal string offset 'tx_yoastseo_dont_use' in ....../PageRenderer/PageMetaRenderer.php line 31" in backend.

For example by clicking on "Function Check" in powermail module. No sence which page is chosen.

https://github.com/Yoast/Yoast-SEO-for-TYPO3/blob/e6b4c3c1c1727c95fa07298fba26aad1b6028f37/Classes/Frontend/PageRenderer/PageMetaRenderer.php#L30

Throwing of such exceptions must be avoided.

How can we reproduce this behavior?

  1. Install powermail extension on CMS 8.7.X
  2. go to the Mails module
  3. click on Function Check

Here is the traceback

#1476107295: PHP Warning: Illegal string offset 'tx_yoastseo_dont_use' in .../typo3conf/ext/yoast_seo/Classes/Frontend/PageRenderer/PageMetaRenderer.php line 35 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
.../vendor/typo3/cms/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 107.

28 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "Illegal string offset 'tx_yoastseo_dont_use'", …Classes/Frontend/PageRenderer/PageMetaRenderer.php", 35, array)

.../typo3conf/ext/yoast_seo/Classes/Frontend/PageRenderer/PageMetaRenderer.php:
00033: //        die();
00034:         if (is_array($config)
00035:             && !(bool)$GLOBALS['TSFE']->page['tx_yoastseo_dont_use']
00036:             && isset(
00037:                 $config['plugin.']['tx_yoastseo.']['settings.'],

27 YoastSeoForTypo3\YoastSeo\Frontend\PageRenderer\PageMetaRenderer::render(array, TYPO3\CMS\Core\Page\PageRenderer)
26 call_user_func_array(array, array)

.../typo3/sysext/core/Classes/Utility/GeneralUtility.php:
03780:                     }
03781:                     // Call method:
03782:                     $content = call_user_func_array([&$classObj, $parts[1]], [&$params, &$ref]);
03783:                 } else {
03784:                     $errorMsg = 'No method name \'' . $parts[1] . '\' in class ' . $parts[0];

25 TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction("YoastSeoForTypo3\YoastSeo\Frontend\PageRenderer\PageMetaRenderer->render", array, TYPO3\CMS\Core\Page\PageRenderer)

.../cms/typo3/sysext/core/Classes/Page/PageRenderer.php:
02791:             ];
02792:             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'] as $hook) {
02793:                 GeneralUtility::callUserFunction($hook, $params, $this);
02794:             }
02795:         }

24 TYPO3\CMS\Core\Page\PageRenderer::executePostRenderHook("<script type="text/javascript">↵/*<![CDATA[*/↵var …189ff95a461e3b63ec14291523c7"}};/*]]>*/↵</script>↵", "<script src="/typo3conf/ext/powermail/Resources/Pu…p.js?1517913962" type="text/javascript"></script>↵", "", "", "<link rel="stylesheet" type="text/css" href="/typo…/Stylesheet/ThemesBackendTca.css" media="screen">↵", "<script type="text/javascript">↵/*<![CDATA[*/↵/*Re…uire(["TYPO3/CMS/Lang/Lang"]);↵↵/*]]>*/↵</script>↵", "", "", "")

.../cms/typo3/sysext/core/Classes/Page/PageRenderer.php:
01865:             $jsInline = '';
01866:         }
01867:         $this->executePostRenderHook($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs);
01868:         return [$jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs];
01869:     }

23 TYPO3\CMS\Core\Page\PageRenderer::renderJavaScriptAndCss()

.../cms/typo3/sysext/core/Classes/Page/PageRenderer.php:
01750:     {
01751:         $this->prepareRendering();
01752:         list($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs) = $this->renderJavaScriptAndCss();
01753:         $metaTags = implode(LF, $this->metaTags);
01754:         $markerArray = $this->getPreparedMarkerArray($jsLibs, $jsFiles, $jsFooterFiles, $cssLibs, $cssFiles, $jsInline, $cssInline, $jsFooterInline, $jsFooterLibs, $metaTags);

22 TYPO3\CMS\Core\Page\PageRenderer::render(1)

.../cms/typo3/sysext/backend/Classes/Template/DocumentTemplate.php:
00630:         }
00631:         // Construct page header.
00632:         $str = $this->pageRenderer->render(PageRenderer::PART_HEADER);
00633:         $this->JScode = ($this->extJScode = '');
00634:         $this->JScodeArray = [];

21 TYPO3\CMS\Backend\Template\DocumentTemplate::startPage("powermail")

.../cms/typo3/sysext/fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php:
00156:         // Render the content and return it
00157:         $output = $this->renderChildren();
00158:         $output = $doc->startPage($pageTitle) . $output;
00159:         $output .= $doc->endPage();
00160:         return $output;

20 TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper::render()
19 call_user_func_array(array, array)

.../cms/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php:
00091: 
00092:         try {
00093:             return call_user_func_array([$this, 'render'], $renderMethodParameters);
00094:         } catch (Exception $exception) {
00095:             if (GeneralUtility::getApplicationContext()->isProduction()) {

18 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::callRenderMethod()

.../typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php:
00248:         $this->initialize();
00249: 
00250:         return $this->callRenderMethod();
00251:     }
00252: 

17 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper::initializeArgumentsAndRender()

.../typo3fluid/fluid/src/Core/ViewHelper/ViewHelperInvoker.php:
00077:             $viewHelper->setArguments($evaluatedArguments);
00078:             $viewHelper->handleAdditionalArguments($undeclaredArguments);
00079:             return $viewHelper->initializeArgumentsAndRender();
00080:         } catch (Exception $error) {
00081:             return $renderingContext->getErrorHandler()->handleViewHelperError($error);

16 TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInvoker::invoke("In2code\Powermail\ViewHelpers\Be\ContainerViewHelper", array, TYPO3\CMS\Fluid\Core\Rendering\RenderingContext, Closure)

.../typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php:
00520:     {
00521:         $viewHelperClassName = get_called_class();
00522:         return $renderingContext->getViewHelperInvoker()->invoke($viewHelperClassName, $arguments, $renderingContext, $renderChildrenClosure);
00523:     }
00524: 

15 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper::renderStatic(array, Closure, TYPO3\CMS\Fluid\Core\Rendering\RenderingContext)

/var/www/vagrant/htdocs/shared/assets/typo3temp/var/Cache/Code/fluid_template/layout_Backend_html_c34614496173b798da9d4f4c9e9c9388a2dd44c9.php:
00794: $arguments1['pageTitle'] = 'powermail';
00795: 
00796: $output0 .= In2code\Powermail\ViewHelpers\Be\ContainerViewHelper::renderStatic($arguments1, $renderChildrenClosure2, $renderingContext);
00797: 
00798: $output0 .= '

14 layout_Backend_html_c34614496173b798da9d4f4c9e9c9388a2dd44c9::render(TYPO3\CMS\Fluid\Core\Rendering\RenderingContext)

.../typo3fluid/fluid/src/View/AbstractTemplateView.php:
00199:             }
00200:             $this->startRendering(self::RENDERING_LAYOUT, $parsedTemplate, $this->baseRenderingContext);
00201:             $output = $parsedLayout->render($this->baseRenderingContext);
00202:             $this->stopRendering();
00203:         }

13 TYPO3Fluid\Fluid\View\AbstractTemplateView::render()

.../cms/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php:
00343: 
00344:         if ($actionResult === null && $this->view instanceof ViewInterface) {
00345:             $this->response->appendContent($this->view->render());
00346:         } elseif (is_string($actionResult) && $actionResult !== '') {
00347:             $this->response->appendContent($actionResult);

12 TYPO3\CMS\Extbase\Mvc\Controller\ActionController::callActionMethod()

.../cms/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php:
00174:             $this->initializeView($this->view);
00175:         }
00176:         $this->callActionMethod();
00177:         $this->renderAssetsForRequest($request);
00178:     }

11 TYPO3\CMS\Extbase\Mvc\Controller\ActionController::processRequest(TYPO3\CMS\Extbase\Mvc\Web\Request, TYPO3\CMS\Extbase\Mvc\Web\Response)

.../cms/typo3/sysext/extbase/Classes/Mvc/Dispatcher.php:
00083:             $controller = $this->resolveController($request);
00084:             try {
00085:                 $controller->processRequest($request, $response);
00086:             } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $ignoredException) {
00087:             }

10 TYPO3\CMS\Extbase\Mvc\Dispatcher::dispatch(TYPO3\CMS\Extbase\Mvc\Web\Request, TYPO3\CMS\Extbase\Mvc\Web\Response)

.../cms/typo3/sysext/extbase/Classes/Mvc/Web/BackendRequestHandler.php:
00030:         /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
00031:         $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Response::class);
00032:         $this->dispatcher->dispatch($request, $response);
00033:         return $response;
00034:     }

9 TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::handleRequest()

.../cms/typo3/sysext/extbase/Classes/Core/Bootstrap.php:
00197:         $requestHandler = $requestHandlerResolver->resolveRequestHandler();
00198: 
00199:         $response = $requestHandler->handleRequest();
00200:         // If response is NULL after handling the request we need to stop
00201:         // This happens for instance, when a USER object was converted to a USER_INT

8 TYPO3\CMS\Extbase\Core\Bootstrap::handleRequest()

.../cms/typo3/sysext/extbase/Classes/Core/Bootstrap.php:
00184:     {
00185:         $this->initialize($configuration);
00186:         return $this->handleRequest();
00187:     }
00188: 

7 TYPO3\CMS\Extbase\Core\Bootstrap::run("", array)

.../cms/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php:
00180:             // Run Extbase
00181:             $bootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
00182:             $content = $bootstrap->run('', $configuration);
00183: 
00184:             $response->getBody()->write($content);

6 TYPO3\CMS\Backend\Http\BackendModuleRequestHandler::dispatchModule("web_PowermailM1")

.../cms/typo3/sysext/backend/Classes/Http/BackendModuleRequestHandler.php:
00087: 
00088:         $moduleName = (string)$this->request->getQueryParams()['M'];
00089:         return $this->dispatchModule($moduleName);
00090:     }
00091: 

5 TYPO3\CMS\Backend\Http\BackendModuleRequestHandler::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)

.../cms/typo3/sysext/core/Classes/Core/Bootstrap.php:
00313: 
00314:         // Execute the command which returns a Response object or NULL
00315:         $this->response = $requestHandler->handleRequest($request);
00316:         return $this;
00317:     }

4 TYPO3\CMS\Core\Core\Bootstrap::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)

.../cms/typo3/sysext/backend/Classes/Http/Application.php:
00090:         }
00091: 
00092:         $this->bootstrap->handleRequest($this->request);
00093: 
00094:         if ($execute !== null) {

3 TYPO3\CMS\Backend\Http\Application::run()

.../cms/typo3/sysext/backend/Resources/Private/Php/backend.php:
00022:     $classLoader = require __DIR__ . '/../../../../../../vendor/autoload.php';
00023: 
00024:     (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00025: });

2 {closure}()

.../cms/typo3/sysext/backend/Resources/Private/Php/backend.php:
00023: 
00024:     (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00025: });

1 require(".../sysext/backend/Resources/Private/Php/backend.php")

.../cms/typo3/index.php:
00001: <?php
00002: 
00003: require __DIR__ . '/sysext/backend/Resources/Private/Php/backend.php';

Technical info

haassie commented 5 years ago

Can you please check this with the latest version available for the plugin? You can use version 3.0.4. I can't reproduce this bug in the latest version.

alessandrofilira commented 5 years ago

Hi @haassie, I have the same problem in my installation. I tried to update version from 3.0.0 to 3.0.5 (the latest) but the problems remains. The TYPO3 version is 8.7.22 and for the moment I fix it adding in extension core "&& isset($GLOBALS['TSFE']->page['tx_yoastseo_dont_use'])" in PageMetaRenderer.php line 30 but I'm not sure about this change. Is it the correct way or I do some configuration mistakes? If you want I can do a pull request.. Thanks for your availability.

akhamuliak commented 5 years ago

same bug for me.

Latest version for TYPO3 8.7 ( 3.0.5 )

Caused because $GLOBALS['TSFE']->page is empty string ' ' at some pages. at others $GLOBALS['TSFE']->page = null, so no error.

(have no idea why, but it's default value in TypoScriptFrontendController class is also ' ')

akhamuliak commented 5 years ago

@haassie Found the reason.

$GLOBALS['TSFE']->page is empty string, because standalone view was rendered in tt_content_drawItem hook. (mask extension)

If some of mask CEs was set at page - $GLOBALS['TSFE']->page = ' ' instead of null.

I think there is no reason to continue debugging. TYPO3 core just allow this case, so it must be handled in PageMetaRenderer

Solution from @alessandrofilira looks good for me.

Pablo-Camara commented 3 years ago

@akhamuliak @alessandrofilira I don't like that solution because, ->page['... is also called in other places, you would have to check everywhere with isset,

For me , this seems to fix it: https://github.com/Yoast/Yoast-SEO-for-TYPO3/pull/447

( but anyways PageMetaRenderer no longer exists I believe, this is a similar issue but for CanonicalGenerator which was causing me error on the backend on the Page module when selecting a page )