Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when $_SERVER['PWD'] is not set #204

Closed
tdierolf opened this issue Feb 15, 2023 · 7 comments · Fixed by #219
Closed

Error when $_SERVER['PWD'] is not set #204

tdierolf opened this issue Feb 15, 2023 · 7 comments · Fixed by #219
Labels
bug Something isn't working

Comments

@tdierolf
Copy link

Hi. When PWD is not set in der $_SERVER vars this error comes up:

In ParallelExecutorFactory.php line 437:
  mb_strpos() expects parameter 2 to be string, null given

It is caused in this method of class ParallelExecutorFactory:

    private static function getScriptPath(): string
    {
        $pwd = $_SERVER['PWD'];
        $scriptName = $_SERVER['SCRIPT_NAME'];

        return 0 === mb_strpos($scriptName, $pwd)
            ? $scriptName
            : $pwd.DIRECTORY_SEPARATOR.$scriptName;
    }

Thanks, kind regards!
Tim

@theofidry
Copy link
Collaborator

Hi thanks for the report!

Would it be possible to have more details about the context of the execution? e.g. platform, OS, PHP version, package version?

@tdierolf
Copy link
Author

tdierolf commented Feb 16, 2023

Yes, sure, sorry! :)

Platform: Linux on AWS ec2
OS: Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-1019-aws x86_64)
PHP: 7.4
Package version: 2.1.0
Application: Symfony 4.4

Quick fix for me was adding the PWD to .env within the application.

Cheers!

@fashxp
Copy link

fashxp commented May 15, 2023

got the same problem when in docker setup like https://github.com/pimcore/demo/blob/11.x/docker-compose.yaml

@theofidry
Copy link
Collaborator

Sorry for the delayed response. I'll have to try but I wonder what we can use as an alternative in this scenario then.

@mohammed-mahmoud-scandi

any updates .... @theofidry

theofidry added a commit to theofidry/console-parallelization that referenced this issue Oct 13, 2023
@theofidry
Copy link
Collaborator

Could anyone try #219 see if that fixes your issue?

@theofidry theofidry added the bug Something isn't working label Oct 13, 2023
@jantom90
Copy link

Hi @theofidry, I tested your PR.
Looks good on Docker, where it gives '/var/www/html' for getcwd and 'bin/console' for $_SERVER['SCRIPT_NAME'].
But, it's different on VPS. There, getcwd returns '/some/storage/vendor/pimcore/pimcore/lib/', and $_SERVER['SCRIPT_NAME'] gives '/some/storage/bin/console'.
We might need an extra check for SCRIPT_NAME.If it's an absolute path, we can just go with that. If not, we can use str_starts_with in the last part of the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants