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

Log warnings that are on the second level also #41

Merged
merged 1 commit into from
Dec 20, 2017
Merged

Log warnings that are on the second level also #41

merged 1 commit into from
Dec 20, 2017

Conversation

Albert221
Copy link
Contributor

@Albert221 Albert221 commented Dec 18, 2017

Bug: T177191

/cc @samwilson

Copy link
Member

@samwilson samwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. A couple of comments.

Note that you could also add a new test, perhaps with the duplicate-upload warning as given in the ticket; that'd make sure this was fixed correctly. :-)

}

foreach ( $value['warnings'] as $module => $warningData ) {
// Accomodate both formatversion=2 and old-style API results
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should not be duplicated from above. Instead, you could a new protected method logWarning() and call it from each of these places.

$this->logger->warning( $logPrefix . $warningData['warnings'], [ 'data' => $warningData ] );
}

return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're returning after the first iteration of the loop. What about if there are multiple warnings?


// ...if no then go one level deeper and check there for them.
foreach ( $result as $value ) {
if ( !array_key_exists( 'warnings', $value ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$value can be a string (see test results).

Copy link
Member

@samwilson samwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Just that little coding-standard fix that Travis is complaining about, and one minor comment.

*
* @return bool Whether any warning has been logged or not.
*/
private function logWarning( $array ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be proteccted, in case subclasses want to do something different with it.

Copy link
Member

@samwilson samwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @addshore are you okay with this?

@addshore addshore merged commit 42f36b4 into addwiki:master Dec 20, 2017
@Albert221 Albert221 deleted the log-warnings-fix branch December 23, 2017 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants