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

Fix logging when logger has no writeExtra method #37454

Merged
merged 1 commit into from
May 27, 2020

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented May 27, 2020

Description

  • Correct the call to \is_callable - the first parameter should be an array whose entries are the object concerned and the name of the hoped-for method in the object.
  • Add a unit test

Related Issue

How Has This Been Tested?

LoggerWithoutWriteExtraTest.php is a cut-down version of LoggerTest.php that does not have a writeExtra method, and just has the relevant test case.

Without the fix in lib/private/Log.php the test fails:

PHPUnit 8.5.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.6 with Xdebug 2.9.5
Configuration: /home/phil/git/owncloud/core/tests/phpunit-autotest.xml

E                                                                   1 / 1 (100%)

Time: 110 ms, Memory: 24.00 MB

There was 1 error:

1) Test\LoggerWithoutWriteExtraTest::testExtraFields
call_user_func() expects parameter 1 to be a valid callback, class 'Test\LoggerWithoutWriteExtraTest' does not have a method 'writeExtra'

/home/phil/git/owncloud/core/lib/private/Log.php:398
/home/phil/git/owncloud/core/lib/private/Log.php:247
/home/phil/git/owncloud/core/tests/lib/LoggerWithoutWriteExtraTest.php:59

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Makefile:189: recipe for target 'test-php-unit' failed
make: *** [test-php-unit] Error 2

That reproduces the error reported in the issue.

With the fix, the test passes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@codecov
Copy link

codecov bot commented May 27, 2020

Codecov Report

Merging #37454 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #37454   +/-   ##
=========================================
  Coverage     64.67%   64.67%           
  Complexity    19332    19332           
=========================================
  Files          1277     1277           
  Lines         75521    75521           
  Branches       1331     1331           
=========================================
  Hits          48846    48846           
  Misses        26283    26283           
  Partials        392      392           
Flag Coverage Δ Complexity Δ
#javascript 54.14% <ø> (ø) 0.00 <ø> (ø)
#phpunit 65.84% <100.00%> (ø) 19332.00 <0.00> (ø)
Impacted Files Coverage Δ Complexity Δ
lib/private/Log.php 82.17% <100.00%> (ø) 49.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f04c9ab...a3da7dd. Read the comment docs.

Copy link
Contributor

@micbar micbar left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@phil-davis phil-davis merged commit ba8dbac into master May 27, 2020
@delete-merged-branch delete-merged-branch bot deleted the fix-logger-writeExtra-37453 branch May 27, 2020 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when logging with a logger that has no writeExtra method
2 participants