Closed ernilambar closed 2 weeks ago
I dug little deep into this issue. Our main issue here starts from the handbook api-dump
command. There are lots of PHP notices in the command output. So the result is not partiucularly valid JSON output. Output of this command is used in gen-all
command. This gen-all
deletes the internal-api
folder and tries to regenerate all markdown file but could not due to invalid JSON result from the above function.
Error is coming around this line - https://github.com/wp-cli/handbook/blob/main/bin/command.php#L622
preg_match( '/@(\w+)/', $info, $matches );
$param_name = $matches[1];
We have assumed here that there will always be match and $matches[1]
is used directly without conditional. So, I am not sure since when this error started.
I checked the git blame but it seems these lines have not been changed since 7 years.
Also in public function gen_api_docs()
method, we have assumed that the output of the command is always valid JSON and used directly. May be we need some sanity check in this method also.
Aside: We really need to add some tests here in this repo.
My bad. Error was introduced in this PR https://github.com/wp-cli/handbook/pull/506
PR https://github.com/wp-cli/handbook/pull/520 should fix the issue.
Bug Report
Describe the current, buggy behavior
When I follow the steps given in https://github.com/wp-cli/handbook#wp-clihandbook there are lots of PHP notices and warnings. All the files in the
internal-api
are deleted.Describe how other contributors can replicate this bug
Describe what you would expect as the correct outcome
Pages should be regenerated properly.
Let us know what environment you are running this on
Provide additional context/Screenshots