Problem/Motivation

In \Drupal\Core\Recipe\ConsoleInputCollector::collectValue, when the method is ask and the value is integer (or generally not a string), then the call to $this->io->$method(...$arguments); throws an exception because the second value needs to be a string.

Proposed resolution

Always cast the default value to string, if the method is "ask".

Issue fork drupal-3559632

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jurgenhaas created an issue. See original summary.

jurgenhaas’s picture

Status: Active » Needs review
phenaproxima’s picture

Status: Needs review » Needs work

Small suggestion for clarity, and a request for a comment.

But otherwise, this is an easy RTBC from me.

jurgenhaas’s picture

I've tried various ways with the test but can't figure out a way to make it work. I'm currently writing a float value in a config object which will be used as default input for the recipe. However, this fails with the error "No schema for config_test.types" whereas the missing schema doesn't seem to be an issue when the recipe writes to that config.

I'm running out of ideas for now, unfortunately.

phenaproxima’s picture

Assigned: Unassigned » phenaproxima

I have some ideas!

phenaproxima’s picture

Assigned: phenaproxima » Unassigned
Status: Needs work » Needs review

Converted it to a more tightly-scoped test that doesn't need to interact with config at all.

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

Test looks good and shows the int -> string conversion. I also confirmed that test-only job fails as expected.

alexpott’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 98172e7a3df to 11.x and 7e79d8d3d86 to 11.3.x. Thanks!

Backported to 11.3.x as a bug fix.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 7e79d8d3 on 11.3.x
    fix: #3559632 Recipe input default value needs to be a string value
    
    By...

  • alexpott committed 98172e7a on 11.x
    fix: #3559632 Recipe input default value needs to be a string value
    
    By...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.