drush icon indicating copy to clipboard operation
drush copied to clipboard

How to interpret the bootstrap property in drush status

Open fiasco opened this issue 2 years ago • 2 comments

Describe the bug When Drush has bootstrapped Drupal successfully, the drush status info will display a property called "bootstrap" with a value of "Successful". Unless your default language is not english. Then it will say something else like "\u6210\u529f" in json format which converts to "成功" for the japanese language.

This is problematic if I want to use this data (which I do) programatically to know if Drupal has successfully bootstrapped, I can't check the bootstrap property value because the value may vary by translation which (a) I may not know and (b) may vary by multisite.

However, the way the code is currently written, I can actually ignore the value of the bootstrap property and just check the property is present in the status information: https://github.com/drush-ops/drush/blob/12.x/src/Commands/core/StatusCommands.php#L122

And this I think is the actual bug: Knowing drush bootstrap can achieve different levels and being a property with a string value, I assumed the property could contain values like "Unsuccessful". In reality, this is a boolean field where its value is indicated by its presence or absence of the field. This value is a translation of a successful bootstrap - though there is no translation available of an unsuccessful bootstrap.

I would propose either:

  1. Add a true boolean flag property to status information so checking if the bootstrap was successful is not a dark art. Or
  2. Document in the code that checking for the presence of this field is how you know the bootstrap was successful so folks like myself can feel assured this is how we're suppose to interact with this value of interpret bootstrap status.

fiasco avatar Jul 18 '23 21:07 fiasco

I don't have a strong feeling between the options. I guess 2. is easier since it doesn't break backward compat for anyone who uses presence as the indicator.

weitzman avatar Jul 19 '23 11:07 weitzman