Skip to content

fix: check index is availability in method SentryHandler::handleBatch #515

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

Conversation

wimulkeman
Copy link
Contributor

When flushing logrecords with the handleBatch method the code now checks if $highets['level'] is available before using it.

fixes #514

When flushing logrecords with the handleBatch method the code now checks if $highets['level'] is available before using it.

fixes getsentry#514
@wimulkeman wimulkeman changed the title fix: check index is availability in method handleBatch fix: check index is availability in method SentryHandler::handleBatch Sep 28, 2021
Copy link
Collaborator

@stayallive stayallive 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 taking the time to create this PR!

In array_reduce the first arguments in the callback value holds the returned value from the last iteration. On initialization this first argument is equal to the third argument provided in the array_reduce instantiation. If no third argument is provided, as is in this case, the default value NULL is used.

Therefore on the first run $highest is equal to NULL and does not have the index 'level' available.

fixes getsentry#514
See https://www.php.net/manual/en/function.array-reduce.php
@stayallive stayallive merged commit 955a38e into getsentry:master Oct 6, 2021
@wimulkeman wimulkeman deleted the 514-check-level-index-available-on-handle-batch branch October 6, 2021 13:47
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.

Checking offset "level" on null value
2 participants