Problem with returning value from shell_exec
-
I hope SKS can help here… I use a great plugin called SitePush to synchronise between my live and test sites. Unfortunately, SitePush was abandoned some years ago by its developer, so there is no support. It has continued to work well for me – until very recently.
I have found the problems, but do not understand why it is failing. It checks that it has access to mysql, mysqldump and rsync with, as one example, the code:
if( ! @shell_exec("mysql --version") ) SitePushErrors::add_error( 'mysql not found, not configured properly or PHP safe mode is preventing it from being run.' );This test is failing, in that null is being returned and the error case set up.
However, if I execute the shell command “mysql —version” it does return the version details, so it seems to be configured properly. SafeMode is OFF.Now for the oddity: if I comment out the test and let it proceed despite the error, everything works as it should – the calls using shell_exec to invoke mysql work fine. [This further confirms that SafeMode is indeed off.]
So it appears to be a problem with returning the result of shell_exec.
So what has changed since it was working as intended? I have updated to WordPress 5.2. Also I moved up to PHP 7.1. I have reverted to PHP 5.6, the lowest that WP 5.2 allows, but this has not fixed it.
So I could just remove the checks and things appear to work. But that seems foolhardy.
If someone can suggest why this problem has arisen, I would really appreciate it.
The topic ‘Problem with returning value from shell_exec’ is closed to new replies.