wp-cli / doctor-command

Diagnose problems within WordPress by running a series of checks for symptoms
MIT License
146 stars 22 forks source link

Add recommendation field and write Plugin_Update recommendation #131

Closed davegaeddert closed 6 years ago

davegaeddert commented 7 years ago

@danielbachhuber let me know how you want to tackle this. I added the field and tested it on one check.

Closes #25

davegaeddert commented 7 years ago

I added a couple examples in the form of tests. But I had another thought on this. What I was looking for originally was a way to get more information on certain failed checks, particularly the ones where the extra detail (like which PHP files were found in uploads) won't fit nicely in a shorter-style summary "message". What if instead of adding 2 more "recommendation" fields, we did this...

Treat the "message" field more like a git commit message. The first line is a summary and should be around 50 (?) characters. After that summary line can be a blank line, and then essentially as much freeform content as you want. It could list out specific plugins/files/themes/etc. in a human readable list, could include reference links, suggestions, etc. By default, only the summary line is shown and maybe a --verbose option (--verbose-message? --message-format=full?) could optionally output all of the content that it may have. So if they have more content they want to present, then they can. And if not, then it just uses the short message that it already has (which in some cases is already enough). That would also make it pretty easy to add to the messages over time instead of worrying about trying to solve them all now so that there aren't blank "recommendation_message" fields. And you could avoid having two recommendation_.* fields, which is a little annoying.

I really like the recommended command idea, and think that's definitely worth playing out (separately). I don't think it will work for all of the checks (ex. php-in-upload), but when it does, people could make pretty slick interactive flows using it (or build an interactive resolution flow into doctor-command itself -- "Want to run wp plugin update akismet to resolve this? y\n: ").

So, short version: an expanded, multiline "message" field that only shows first line by default + a separate recommended command field when applicable

@danielbachhuber do you have thoughts on this? Let me know if any of that didn't make sense.

danielbachhuber commented 7 years ago

What I was looking for originally was a way to get more information on certain failed checks, particularly the ones where the extra detail (like which PHP files were found in uploads) won't fit nicely in a shorter-style summary "message".

Oh right. I was thinking these could go in a data field (or something better named). I think it needs to be in a separate field though, because it could be a huge amount of data and probably wouldn't be something you want to try to parse out of a message.

I really like the recommended command idea, and think that's definitely worth playing out (separately). I don't think it will work for all of the checks (ex. php-in-upload), but when it does, people could make pretty slick interactive flows using it (or build an interactive resolution flow into doctor-command itself

Correct and correct :)

davegaeddert commented 7 years ago

Can you give an example of what would be in the data field for the php-in-upload check? Would it be the file paths separated by newlines?

danielbachhuber commented 7 years ago

Can you give an example of what would be in the data field for the php-in-upload check? Would it be the file paths separated by newlines?

It would be the file path relative to WordPress root in JSON format. In --format=table, the JSON would be rendered within the table. In --format=json, it would be true JSON.

davegaeddert commented 6 years ago

I'm still planning to work on this (we need it), just been caught up in my own stuff. I opened #136 and will probably start over with a new PR when I have time.