Fixed cli upgrade error

maszd

Well-known member
Hi i get this message when upgrade via cli :

2018-03-15_055809.webp

this is nostification appear on acp
Code:
Server error log

    ErrorException: [E_RECOVERABLE_ERROR] Object of class XF\Install\Language could not be converted to string src/vendor/symfony/console/Formatter/OutputFormatter.php:133

    Generated by: Unknown account Mar 15, 2018 at 5:56 AM

Stack trace

#0 src/vendor/symfony/console/Formatter/OutputFormatter.php(133): XF::handlePhpError(4096, '[E_RECOVERABLE_...', '/usr/share/ngin...', 133, Array)
#1 src/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format(Object(XF\Install\Language))
#2 src/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 1)
#3 src/XF/Cli/Runner.php(108): Symfony\Component\Console\Output\Output->writeln(Object(XF\Phrase))
#4 src/XF/Cli/Runner.php(64): XF\Cli\Runner->postExecutionCleanUp(Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 cmd.php(15): XF\Cli\Runner->run()
#6 {main}

Request state

array(4) {
  ["url"] => string(0) ""
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

thanks.
 
I think you can add a dummy __toString method to the XF\Install\Language class as a temporary workaround.
PHP:
public function __toString()
{
    return "Language";
}
 
The correct fix for this is to change line 108 of XF\Cli\Runner to:
PHP:
$output->writeln(strval($runner->statusMessage));

Most jobs produce a Phrase object as the status message. The Symfony console component casts any messages to an array. The first element of this array ends up being a XF\Install\Language object, hence the error. Casting it to a string beforehand gets the string value of the phrase only.
 
Anything to do for us who's already upgraded?
Except that error after cli upgrade, everything is working OK.

Should we change that line now or nothing to do?
 
It says it's a recoverable error and regardless it would have happened after everything else had run, so no, it's safe to ignore. The worst that would have happened is that the server stats weren't collected, but that's not a big deal (though I think this error would have happened after they were submitted).
 
Back
Top Bottom