Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken table layout when reporting WordPress vulnerabilities. #134

Open
oscarssanchez opened this issue Jul 24, 2018 · 4 comments
Open

Broken table layout when reporting WordPress vulnerabilities. #134

oscarssanchez opened this issue Jul 24, 2018 · 4 comments

Comments

@oscarssanchez
Copy link

Hi,

Running wp vuln status through WordPress 4.9.6 breaks the table layout when the package reports any vulnerabilities with WordPress version (not plugins, not themes. See screenshots).

Expected behavior:

Table layout is not broken. Expected to see the same layout as it is with the reports of plugins and themes.

Current behavior:

The table layout breaks.

Steps to reproduce:

Run wp-vulnerability scanner through a WordPress 4.9.6 install
1.- wp vuln status

WP-CLI version: 2.0.0-alpha-2646dac

Screenshots:

Layout broken when reporting problems with WordPress 4.9.6:
vuln1

Layout is fine when reporting no vulnerabilities with WordPress 4.9.7
vuln2

It seems like it has been a recurring issue (#106)

Thank you!

@schlessera
Copy link
Member

@oscarssanchez This issue was fixed, however we couldn't fixed it in a general way without breaking backwards-compat.

That's why you need to use the second argument to display_items() to make this work.

If you pass all of your columns through WP_CLI::colorize(), then pass true as the second argument to display_items().

If you pass only select columns through WP_CLI::colorize(), then pass an array of booleans to display_items(), with each boolean denoting whether the respective column is using WP_CLI::colorize().

So, for example, if you have 4 columns and only the first one is passed through WP_CLI::colorize(), then use array( true, false, false, false ) as the second argument to display_items().

Please let me know if that helps resolve the issue.

@UVLabs
Copy link

UVLabs commented Oct 26, 2021

@schlessera The new function to display a table seems to now be \WP_CLI\Utils\format_items so how do we address this with that function? The third param seems to just take in the column names

\WP_CLI\Utils\format_items( 'table', $items, array( 'module', 'key', 'status' ) );

@alexisferat
Copy link

@schlessera I encountered the same issue as @UVLabs and would like to know if there is a solution or a workaround.

@slaFFik
Copy link
Contributor

slaFFik commented Sep 28, 2023

@UVLabs @alexisferat
Use a custom table registration instead of a generic \WP_CLI\Utils\format_items( 'table', $items ):

$table  = new \cli\Table();
$ascii  = new \cli\table\Ascii( [
	Colors::width( 'value 1', true ),
	Colors::width( 'value 2', false ),
	Colors::width( 'value 3', false )
] );

$ascii->setWidths( $widths );
$table->setRenderer( $ascii );

$table->setHeaders( [ 'module', 'key', 'status' ] );

$table->addRows( [ $rows ] );

$table->display();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants