Unset _style during encode/decode of backend packets to avoid type mismatch errors #3776
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a drush command uses a Robo collection (or perhaps just a Robo task—untested), and that command is invoked as a backend process, and that command fails, you may see an error like this:
After some debugging, it turns out this is because
Robo\Log\ResultPrinter
sets['_style']['message']
to an empty string, which then gets encoded to json. When the "frontend" process then decodes this json,['_style']
is decoded as astdClass
. This subsequently results in an unsupported operand error inConsolidation\Log\LogOutputStyler::style()
as that function expects_style
to be an array.The attached patch strips
_style
from the packet prior to encoded and subsequent to decoding. You may wonder why the latter is necessary if the former is done, but remember that different versions of drush may be involved, so an older version of drush may happily send along the_style
and recreate the same error on a newer version of drush. Cleaning up in both places should avoid this possibility.