Coder Social home page Coder Social logo

Comments (18)

opicron avatar opicron commented on May 28, 2024 5

When I undo the last patch and replace:

$process = Process::fromShellCommandline($command);

With:

$process = new Process($command);

The script works again..

from image-optimize-command.

eboy79 avatar eboy79 commented on May 28, 2024 2

thank you opicron!
$process = new Process($command);

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024 2

Solution found: Install wp cli via composer instead of phar.

This is because phar bundles with symfony/process v2 and v2 is always loaded (even though a newer version of it is installed).

Using composer resolve the issue.

For those using Trellis, check out https://github.com/ItinerisLtd/trellis_install_wp_cli_via_composer

Re-open this issue if you have a better solution.

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

Although I see Installing symfony/process (v4.2.3), can you confirm symfony/process v4.2.3 is loaded?

Related:

Tips:
WP CLI doesn't provide easy way to check it. My suggestion would be looking into your wp package path. You will find the underlying composer installation there.

from image-optimize-command.

opicron avatar opicron commented on May 28, 2024

I am unsure how to check if the symfony/process is loaded. However checking the /vendor/symfony/process/ path the php scripts are installed.

Running the install command an second time gives no warnings or errors. I assume the correct version is installed.

EDIT: The process component Changlog states 4.2.0.

I manually downloaded symfony/process 4.2.3 and replaced the old version. I uploaded an new image and tried to optimize it but it fails with the same error.

from image-optimize-command.

artur-swoboda avatar artur-swoboda commented on May 28, 2024

This is still a valid error :(

But can be fixed with changes from above.

from image-optimize-command.

Redjam avatar Redjam commented on May 28, 2024

Error is still valid. The fix proposed by @opicron works well. Is it possible du push it in the branch for future users?

from image-optimize-command.

jbonlinea avatar jbonlinea commented on May 28, 2024

Hi guys

I bumped into the same error as you

could you please detail what changes have you made ?

When I undo the last patch and replace:

$process = Process::fromShellCommandline($command);

With:

$process = new Process($command);

The script works again..

what last patch, and what file have you edited ?

Thank's

EDIT

the file to edit is
/.wp-cli/packages/vendor/spatie/image-optimizer/src/OptimizerChain.php:97

It works indeed, but I haven't "downgraded to last patch (which is ?)

from image-optimize-command.

Soullighter avatar Soullighter commented on May 28, 2024

I hade same error, after replace with @opicron suggestions everything is working fine
Thank you @jbonlinea for directing us to the file 👍

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

Which version you installed?
Is it 482d9c9 ?

from image-optimize-command.

Soullighter avatar Soullighter commented on May 28, 2024

Which version you installed?
Is it 482d9c9 ?

You mean on composer.json?
How to check version?

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

Finally found the issue - wp cli phar bundles symfony/process v2 which got loaded no matter which versions we specified in our (and our dependencies') composer.json.

Solution to be investigated. Leave a comment if you have any suggestions.

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

more info:

$ wp shell

wp> $reflector = new \ReflectionClass('Symfony\Component\Process\Process');
=> object(ReflectionClass)#2801 (1) {
  ["name"]=>
  string(33) "Symfony\Component\Process\Process"
}
wp> echo $reflector->getFileName();
phar:///usr/bin/wp/vendor/symfony/process/Process.php
wp>

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

spatie/image-optimizer requires symfony/process ^4.2|^5.0.

WP CLI bundle installs symfony/process v2.8.52.

Conclusion: WP CLI bundle won't work. Install WP CLI via composer instead. See: requirements

from image-optimize-command.

ibrahimhajjaj avatar ibrahimhajjaj commented on May 28, 2024

When I undo the last patch and replace:

$process = Process::fromShellCommandline($command);

With:

$process = new Process($command);

The script works again..

Step by step for others who don't know

nano /root/.wp-cli/packages/vendor/spatie/image-optimizer/src/OptimizerChain.php
CTRL + W and paste this Process::fromShellCommandline($command) and press enter
changer it with new Process($command)

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

Don't do that.
Install WP CLI via composer instead. See: requirements

from image-optimize-command.

ibrahimhajjaj avatar ibrahimhajjaj commented on May 28, 2024

Don't do that.
Install WP CLI via composer instead. See: requirements

I've tried that but didn't fix the problem for me.

from image-optimize-command.

tangrufus avatar tangrufus commented on May 28, 2024

Editing vendor code won't work neither.

Send bug report if you are facing the same issue with wp cli installed via composer.

from image-optimize-command.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.