0

I'm trying to do a custom wordpress core upgrade through wp-cli, theres an GUI upgrade hang issue in kubernetes when AWS EFS storage is used. For me wp core upgrade works great. I need somekind of binding to the upgrade button in the gui, when clicked it should invoke the custom_upgrade.php script which will do shell execution. I'm pretty new to php and wordpress. Here's a sample script provided by mwithheld: https://github.com/wp-cli/wp-cli/issues/1924

  • Is this a replacement for your other question from yesterday? I have answered the command execution part via PHP in this thread, but I wouldn't recommend doing that. Fixing the cause instead of treating the symptom makes more sense IMHO. – swissspidy Jan 23 '18 at 13:22
  • @swissspidy You are right about fixing the cause, i was trying this custom php script solution and found about the timouts from openshift (Kubernetes) router (haproxy), increased the timeout and it worked perfectly. – karthik101 Jan 25 '18 at 8:16
0

This is a php script that can execute wp-cli, Keep the file in wp-admin/ folder and visit www.example-wordpress.com/wp-admin/execute_cli.php to run the script. This is just for test purposes and not a good way to use.

execute_cli.php

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', '1');
echo "<PRE>\n";

if(!defined('STDIN'))  define('STDIN',  fopen('php://stdin',  'r'));
if(!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'w'));
if(!defined('STDERR')) define('STDERR', fopen('php://stdout', 'w'));

echo "Started\n\n";
$return_status = false;
$output = array();
//$executable = '/path/to/php-executable -c /path/to/php.ini -d error_reporting="E_ALL & ~E_NOTICE" -d memory_limit="2048M" -d max_execution_time=43200 wp-cli.phar ';
//Redirect stdERR so we see warnings/errors
$suffix = ' 2>&1';
//echo 'Built executable='.$executable."\n";

//$command = 'user delete johnsmithfake --network --yes';
$command = 'wp core update';
//$full_command = $executable.$command.$suffix;
$full_command = $command.$suffix;

echo "About to execute command=\n{$full_command}\n";
exec($full_command, $output, $return_var);

echo "---------------\n";
echo implode("\n", $output)."\n";
echo "---------------\n";
echo "Return status (false/0 is success)=".($return_status?1:0)."\n";

echo "\nDone</PRE>\n";
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.