GithubHelp home page GithubHelp logo

cannot access private method about monolog HOT 7 CLOSED

buexplain avatar buexplain commented on June 14, 2024 2
cannot access private method

from monolog.

Comments (7)

Seldaek avatar Seldaek commented on June 14, 2024 1

Great, thanks for the investigative work there! I guess maybe using a closure instead would be better, otherwise public method with an internal phpdoc.. Anyway I'll look at this next week

from monolog.

Seldaek avatar Seldaek commented on June 14, 2024

This is weird.. I can't reproduce it (https://3v4l.org/ZHA87) and I don't really see why it would do this as the callback is only used within the context of StreamHandler /cc @corentin-cres

from monolog.

lcharette avatar lcharette commented on June 14, 2024

I was able to replicate this UserFrosting by removing write permission to the log file, which resulted in a similar error message :

Fatal error: Uncaught Error: Invalid callback Monolog\Handler\StreamHandler::customErrorHandler, cannot access private method Monolog\Handler\StreamHandler::customErrorHandler()

Using the example above (https://3v4l.org/ZHA87) on the same environment and on the same file (without write access) returned the proper output :

string(40) "Failed to open stream: Permission denied" string(9) "Test test" 

The difference is our app use a custom StreamWrapper. So the core PHP fopen isn't actually called by Monolog's StreamHandler, but our own. And both will invoke customErrorHandler, which won't work on our side since the method is private. Therefore, customErrorHandler must be public.

Note the actual process when customErrorHandler is public is similar to this :

  1. Monolog StreamHandler call fopen
  2. Our own StreamHandler calls fopen
  3. fopen trows an exception
  4. Our StreamHandler invoke customErrorHandler (even if we use @fopen), then do the rest of it's job and return false.
  5. Monolog invoke customErrorHandler again

from monolog.

lcharette avatar lcharette commented on June 14, 2024

Here's a way to replicate : https://3v4l.org/PjtpI

(Forget the open_basedir restriction in effect error... that means it's working, simply I can't replicate a non-writable file on the editor)

There we go. Both should return "Failed to open stream" : https://3v4l.org/LsBph

from monolog.

Seldaek avatar Seldaek commented on June 14, 2024

@lcharette can you please check using dev-main if this problem is fixed for you?

from monolog.

lcharette avatar lcharette commented on June 14, 2024

I confirm problem is fixed with dev-main. Thanks !

from monolog.

Seldaek avatar Seldaek commented on June 14, 2024

Great

from monolog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.