Validate package instance before checking execution policy

This commit is contained in:
netkas 2024-10-25 19:59:22 -04:00
parent 41947069be
commit 544d4ebdf6
2 changed files with 9 additions and 6 deletions

View file

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This update introduces critical bug fixes This update introduces critical bug fixes
### Fixed
- Validate package instance before checking execution policy
## [2.1.5] - 2024-10-14 ## [2.1.5] - 2024-10-14

View file

@ -94,14 +94,14 @@
throw new InvalidArgumentException(sprintf('Package %s is not imported', $package)); throw new InvalidArgumentException(sprintf('Package %s is not imported', $package));
} }
if(self::$imported_packages[$package]?->getMetadata()?->getMainExecutionPolicy() === null)
{
Console::out('The package does not have a main execution policy, skipping execution');
return 0;
}
if(self::$imported_packages[$package] instanceof PackageReader) if(self::$imported_packages[$package] instanceof PackageReader)
{ {
if(self::$imported_packages[$package]?->getMetadata()?->getMainExecutionPolicy() === null)
{
Console::out('The package does not have a main execution policy, skipping execution');
return 0;
}
return ExecutionUnitRunner::executeFromPackage( return ExecutionUnitRunner::executeFromPackage(
self::$imported_packages[$package], self::$imported_packages[$package],
self::$imported_packages[$package]->getMetadata()->getMainExecutionPolicy() self::$imported_packages[$package]->getMetadata()->getMainExecutionPolicy()