Skip to content

HTTP 500 error on job execution: "Typed property Configuration::$executorSettings must not be accessed before initialization" #204

Description

@APochmann

I run into this issue since migration to pimcore 11 (and therefore ProcessManager 5.x). It seems it's an issue that I do not use predefined configuration but start the job directly and fill some data in the callback function. With ProcessManager 4.x I used parameter $configId = null which gave an error in new version so I use empty string now:

        $jobResult = Helper::executeJob(
                '',                               // $configId
                [],                               // $callbackSettings = []
                $this->getPimcoreUser()->getId(), // $userId = 0
                $metadata,                        // $metaData = '[]'
                null,                             // $parentMonitoringItemId = null
                'App\Helper\ProcessHelper::processCallback');

executeJob recognizes there is no Configuration and creates a new one but with this one getExecutorClassObject fails:

    public static function executeJob(string $configId, array $callbackSettings = [], int $userId = 0, mixed $metaData = [], mixed $parentMonitoringItemId = null, ?callable $callback = null)
    {
        try {
            $config = Configuration::getById($configId);

            if(!$config instanceof \Elements\Bundle\ProcessManagerBundle\Model\Configuration) {
                $config = new Configuration();
                $config->setExecutorClass(Executor\PimcoreCommand::class);
            }

            $executor = $config->getExecutorClassObject();

getExecutorClassObject (method of Configuration class) is failing on calling setDataFromResource by passing its own instance created in executeJob:

    public function getExecutorClassObject(): AbstractExecutor
    {
        if (!isset($this->executorClassObject)) {

            $className = $this->getExecutorClass();
            $class = new $className();
            $class->setDataFromResource($this);

setDataFromResource in AbstractExecuter class tries to get Executer settings

    public function setDataFromResource(Configuration $configuration): Configuration
    {
        $settings = $configuration->getExecutorSettings();

getExecutorSettings (method of Configuration class) finally raises the exception as global variable $this->executorSettings is not initialized yet:

    public function getExecutorSettings(): string
    {
        return $this->executorSettings;
    }

I assume, having no predefined configuration is still a valid use case as executeJob handles that by creating a new Configuration instance. It just seems that this new instance is not initialized in a functional way

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions