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

sprintf(): Too few arguments #124

Open
nahkampf opened this issue Feb 28, 2018 · 2 comments
Open

sprintf(): Too few arguments #124

nahkampf opened this issue Feb 28, 2018 · 2 comments

Comments

@nahkampf
Copy link

Can't really figure this one out. Sometimes (not often, but often enough to end up in my logs and irritate me) \cli\line() causes a warning: sprintf(): Too few arguments.

This is the offending line:

\cli\line("[%C%k%s%N] Starting!", date("Y-m-d H:i:s"));

Can't really see how the argument to sprintf() gets lost here, but obv it does.

environment: php5.6.33 (with mbstring) on debian, php-cli-tools v0.11.8.

Logfile trace:

in function LoggingErrorHandler::handleError
in function call_user_func in /foo/include/classes/LoggingErrorHandler.php on line 402
in function LoggingErrorHandler::{closure}
in function sprintf
in function call_user_func_array in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 48
in function cli\Streams::render
in function call_user_func_array in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 13
in function cli\Streams::_call in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 68
in function cli\Streams::out
in function call_user_func_array in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 13
in function cli\Streams::_call in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 95
in function cli\Streams::line
in function call_user_func_array in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/Streams.php on line 13
in function cli\Streams::_call in /foo/include/deps/wp-cli/php-cli-tools/lib/cli/cli.php on line 62
in function cli\line in /foo/bin/my_foobar_script.php on line 35
@gitlost
Copy link
Contributor

gitlost commented Mar 2, 2018

Thanks for the report @nahkampf , yes, this is a bug introduced by me in #107 where Streams::render() no longer strips the color percent codes if Colors::shouldColorize() is not true, so sprintf() complains about them and (worse) doesn't output correctly.

This in turn was prompted by not wanting percent codes to be stripped when printing standard data.

So a bit of a mess really, and not sure there's a way to accommodate both issues.

A workaround is to just colorize oneself, eg

\cli\line(\cli\Colors::colorize("[%C%k%s%N] Starting!"), date("Y-m-d H:i:s"));

but this is obviously a bit yuck. Will consider the problem further to see if there's a solution...

@nahkampf
Copy link
Author

nahkampf commented Mar 5, 2018

Ah, thanks! Yucky workaround but I'll take it :)

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

2 participants