Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295735

askHidden prompt fails with "Unknown named parameter $default"

$
0
0

Problem/Motivation

Trying my first recipe with an input and tried to use the prompt type "askHidden", which is listed as supported in \Drupal\Core\Recipe\Recipe and in https://git.drupalcode.org/project/distributions_recipes/-/blob/1.0.x/do....

However when attempting to apply a recipe, an error is displayed.

This is because the ConsoleInputCollector always provides "default" as a parameter to the prompt method, but askHidden is the only prompt that does not take the $default named parameter and fails with a PHP Error.

Error:

Error: Unknown named parameter $default in /var/www/html/webroot/core/lib/Drupal/Core/Recipe/ConsoleInputCollector.php on line 105
#0 /var/www/html/webroot/core/lib/Drupal/Core/Recipe/InputConfigurator.php(154): Drupal\Core\Recipe\ConsoleInputCollector->collectValue()
#1 /var/www/html/webroot/core/lib/Drupal/Core/Recipe/RecipeCommand.php(76): Drupal\Core\Recipe\InputConfigurator->collectAll()
#2 /var/www/html/vendor/symfony/console/Command/Command.php(279): Drupal\Core\Recipe\RecipeCommand->execute()
#3 /var/www/html/vendor/symfony/console/Application.php(1076): Symfony\Component\Console\Command\Command->run()
#4 /var/www/html/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand()
#5 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun()
#6 /var/www/html/webroot/core/scripts/drupal(32): Symfony\Component\Console\Application->run()
#7 {main}

Steps to reproduce

  • Prepare a Drupal installation.
  • Add a directory recipes/askhidden
  • Add a recipe.yml
  • ddev ssh
  • Run cd web
  • Run php core/scripts/drupal recipe ../recipes/askhidden -v

I used the following minimal recipe to reproduce.

name: 'Ask Hidden Test'
description: 'Provides a minimal example for askHidden prompt.'
type: 'Test'

input:
  foo:
    data_type: string
    description: 'Foo'
    prompt:
      method: askHidden
      arguments:
        question: 'What is foo?'
    default:
      source: value
      value: 'bar'

config:
  strict: false

Omitting arguments or trying to provide arguments.default does not matter. The same error is thrown.

Switching to "ask" works.

Proposed resolution

Do not provide a 'default' key to the arguments when the method is askHidden. This is the only prompt that does not take the named parameter default.

Remaining tasks

- Review approach and kernel test
- Commit

User interface changes

No

Introduced terminology

No

API changes

No

Data model changes

No

Release notes snippet


Viewing all articles
Browse latest Browse all 295735


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>