Actions
Bug #99024
closedClassAliasLoader::loadOriginalClassAndSetAliases logged PHP Warning: Invalid argument supplied for foreach() in vendor/typo3/class-alias-loader/src/ClassAliasLoader.php line 175
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
System/Bootstrap/Configuration
Target version:
-
Start date:
2022-11-08
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
logging
Complexity:
easy
Is Regression:
Sprint Focus:
Description
In the function \TYPO3\ClassAliasLoader\ClassAliasLoader::loadOriginalClassAndSetAliases() should be test $this->aliasMap['classNameToAliasMapping'][$originalClassName] with isset() and is_array().
In normal Case is $this->aliasMap['classNameToAliasMapping'][$originalClassName] === null and it will be log the foloow Error:
PHP Warning: Invalid argument supplied for foreach() in vendor/typo3/class-alias-loader/src/ClassAliasLoader.php line 175
original Code:
/** * Load classes and set aliases. * The class_exists calls are safety guards to avoid fatals when * class files were included or aliases were set manually in userland code. * * @param string $originalClassName * @return bool|null */ protected function loadOriginalClassAndSetAliases($originalClassName) { if ($this->classOrInterfaceExists($originalClassName) || $this->loadClass($originalClassName)) { foreach ($this->aliasMap['classNameToAliasMapping'][$originalClassName] as $aliasClassName) { if (!$this->classOrInterfaceExists($aliasClassName)) { class_alias($originalClassName, $aliasClassName); } } return true; } else { //dump('else', $originalClassName); } //dump($originalClassName,$this->aliasMap,$this->aliasMap['classNameToAliasMapping'][$originalClassName]); return null; }
better Code version:
/** * Load classes and set aliases. * The class_exists calls are safety guards to avoid fatals when * class files were included or aliases were set manually in userland code. * * @param string $originalClassName * @return bool|null */ protected function loadOriginalClassAndSetAliases($originalClassName) { if ($this->classOrInterfaceExists($originalClassName) || $this->loadClass($originalClassName)) { if(isset($this->aliasMap['classNameToAliasMapping'][$originalClassName]) && is_array($this->aliasMap['classNameToAliasMapping'][$originalClassName])) { foreach ($this->aliasMap['classNameToAliasMapping'][$originalClassName] as $aliasClassName) { if (!$this->classOrInterfaceExists($aliasClassName)) { class_alias($originalClassName, $aliasClassName); } } } return true; } else { //dump('else', $originalClassName); } //dump($originalClassName,$this->aliasMap,$this->aliasMap['classNameToAliasMapping'][$originalClassName]); return null; }
Here the fisrt entries of my $this->aliasMap
^ array:2 [▼ "aliasToClassNameMapping" => [] "classNameToAliasMapping" => array:3623 [▼ "TYPO3\ClassAliasLoader\ClassAliasMap" => null "TYPO3\CMS\Core\Core\SystemEnvironmentBuilder" => null "TYPO3\CMS\Core\Utility\GeneralUtility" => null "TYPO3\CMS\Core\Core\Environment" => null "TYPO3\CMS\Core\Utility\PathUtility" => null "TYPO3\CMS\Core\Core\ApplicationContext" => null "Symfony\Polyfill\Php80\Php80" => null "TYPO3\CMS\Core\Core\Bootstrap" => null "TYPO3\CMS\Core\Core\RequestId" => null "TYPO3\CMS\Core\Utility\StringUtility" => null "TYPO3\CMS\Core\Core\ClassLoadingInformation" => null "Doctrine\Common\Annotations\AnnotationRegistry" => null "Doctrine\Common\Annotations\AnnotationReader" => null "Doctrine\Common\Annotations\Reader" => null "Doctrine\Common\Annotations\ImplicitlyIgnoredAnnotationNames" => null "TYPO3\CMS\Core\Configuration\ConfigurationManager" => null "TYPO3\CMS\Core\LinkHandling\LinkHandlingInterface" => null "TYPO3\CMS\Core\Log\LogLevel" => null "Psr\Log\LogLevel" => null "TYPO3\CMS\Core\Utility\ArrayUtility" => null "TYPO3\CMS\Core\Log\LogManager" => null "TYPO3\CMS\Core\SingletonInterface" => null "TYPO3\CMS\Core\Log\LogManagerInterface" => null "TYPO3\CMS\Core\Log\Logger" => null "Psr\Log\AbstractLogger" => null "Psr\Log\LoggerInterface" => null "TYPO3\CMS\Core\Error\ErrorHandler" => null "TYPO3\CMS\Core\Error\ErrorHandlerInterface" => null "Psr\Log\LoggerAwareInterface" => null "Psr\Log\LoggerAwareTrait" => null "TYPO3\CMS\Core\Log\Writer\FileWriter" => null "TYPO3\CMS\Core\Log\Writer\AbstractWriter" => null "TYPO3\CMS\Core\Log\Writer\WriterInterface" => null "TYPO3\CMS\Core\Security\BlockSerializationTrait" => null "TYPO3\CMS\Core\Error\DebugExceptionHandler" => null "TYPO3\CMS\Core\Error\AbstractExceptionHandler" => null "TYPO3\CMS\Core\Error\ExceptionHandlerInterface" => null "TYPO3\PharStreamWrapper\Manager" => null "TYPO3\PharStreamWrapper\Behavior" => null "TYPO3\PharStreamWrapper\Assertable" => null "TYPO3\PharStreamWrapper\Interceptor\ConjunctionInterceptor" => null "TYPO3\CMS\Core\IO\PharStreamWrapperInterceptor" => null "TYPO3\PharStreamWrapper\Interceptor\PharMetaDataInterceptor" => null "TYPO3\PharStreamWrapper\Resolver\PharInvocationCollection" => null "TYPO3\PharStreamWrapper\Collectable" => null "TYPO3\PharStreamWrapper\Resolver\PharInvocationResolver" => null "TYPO3\PharStreamWrapper\Resolvable" => null "TYPO3\PharStreamWrapper\PharStreamWrapper" => null "TYPO3\CMS\Core\Cache\Backend\NullBackend" => null "TYPO3\CMS\Core\Cache\Backend\AbstractBackend" => null "TYPO3\CMS\Core\Cache\Backend\BackendInterface" => null "TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface" => null "TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface" => null "TYPO3\CMS\Core\Cache\Frontend\PhpFrontend" => null "TYPO3\CMS\Core\Cache\Frontend\AbstractFrontend" => null "TYPO3\CMS\Core\Cache\Frontend\FrontendInterface" => null "TYPO3\CMS\Core\Package\Cache\PackageStatesPackageCache" => null "TYPO3\CMS\Core\Package\Cache\PackageCacheInterface" => null "TYPO3\CMS\Core\Service\DependencyOrderingService" => null "TYPO3\CMS\Core\Package\PackageManager" => null "TYPO3\CMS\Core\Information\Typo3Version" => null "TYPO3\CMS\Core\Package\Cache\PackageCacheEntry" => null "TYPO3\CMS\Core\Package\Exception\PackageStatesUnavailableException" => null "TYPO3\CMS\Core\Package\Exception" => null "TYPO3\CMS\Core\Exception" => null "TYPO3\CMS\Core\Package\Exception\PackageManagerCacheUnavailableException" => null "TYPO3\CMS\Core\Package\Package" => null "TYPO3\CMS\Core\Package\PackageInterface" => null "TYPO3\CMS\Core\Package\MetaData" => null "TYPO3\CMS\Core\Package\MetaData\PackageConstraint" => null "TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend" => null "TYPO3\CMS\Core\Cache\Frontend\VariableFrontend" => null "TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend" => null "TYPO3\CMS\Core\DependencyInjection\ContainerBuilder" => null "TYPO3\CMS\Core\DependencyInjection\ServiceProviderRegistry" => null .....
Files
Actions