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 in ShellJob.php with Symfony\Component\Process\Process in cron bundle v3.0.0 #133

Closed
andresRG95 opened this issue Jan 15, 2024 · 0 comments

Comments

@andresRG95
Copy link

andresRG95 commented Jan 15, 2024

Hello,

I've encountered an issue when running the php bin/console cron:run command with version 3.0.0 of the cron bundle. The error is as follows:

Symfony\Component\Process\Process::__construct(): Argument #1 ($command) must be of type array, string given, called in /var/www/html/vendor/cron/cron/src/Cron/Job/ShellJob.php on line 27

I am using Symfony 7, PHP 8.2 and the latest version of the cron bundle. I found that the problem is due to ShellJob.php expecting a string for the command, whereas Symfony\Component\Process\Process requires an array.

I have modified the ShellJob.php file as follows to resolve the issue:

<?php
// ... [rest of the file header]

namespace Cron\Job;

use Symfony\Component\Process\Process;

class ShellJob extends AbstractProcessJob
{
    public function setCommand($command)
    {
        $commandArray = explode(' ', $command);
        $this->process = new Process($commandArray);
    }
}

With this modification, the cron works correctly. Would this be a viable solution to integrate into the bundle? Or is there another preferred solution to this issue?

Thank you for your attention.

Bukashk0zzz added a commit to Bukashk0zzz/Symfony-Bundle that referenced this issue Jan 16, 2024
Bukashk0zzz added a commit to Bukashk0zzz/Symfony-Bundle that referenced this issue Jan 16, 2024
NoUseFreak pushed a commit that referenced this issue Jan 28, 2024
* Fix issue #133 Symfony 7 not run jobs

* Fix issue #133 Symfony 7 not run jobs
NoUseFreak added a commit that referenced this issue Feb 17, 2024
NoUseFreak added a commit that referenced this issue Feb 17, 2024
nastia-vinnytska added a commit to nastia-vinnytska/Symfony-Bundle that referenced this issue Apr 23, 2024
NoUseFreak pushed a commit that referenced this issue Apr 27, 2024
* use named arguments for doctrine backwards compatibility

* use array for command arument (fix #133 issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants