Skip to content
Snippets Groups Projects
Commit 3026ddc1 authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Christian Kuhn
Browse files

[TASK] Fix possible null pointer exception

AbstractTreeView defines the current "scriptUrl",
to build links in the backend. Since this class
may also be called via CLI, e.g. by EXT:impexp,
missing `instanceof` checks are added to prevent
a null pointer exception.

Resolves: #94947
Related: #93158
Releases: master
Change-Id: I795effd17d42944ae0ab32b1ab10cd632ca7c31e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70689


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarAlexander Nitsche <typo3@alexandernitsche.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarAlexander Nitsche <typo3@alexandernitsche.com>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 55e6b3a9
No related merge requests found
......@@ -15,6 +15,8 @@
namespace TYPO3\CMS\Backend\Tree\View;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\Route;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
......@@ -176,9 +178,13 @@ abstract class AbstractTreeView
*/
protected function determineScriptUrl()
{
$this->thisScript = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath(
$GLOBALS['TYPO3_REQUEST']->getAttribute('route')->getPath()
);
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ($route = $GLOBALS['TYPO3_REQUEST']->getAttribute('route')) instanceof Route
) {
$this->thisScript = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoutePath(
$route->getPath()
);
}
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment