Child pages
  • [system log] Don't log errors, that originate from 3rd party libraries [5.2.1]
Skip to end of metadata
Go to start of metadata

In one of the projects we're using TCPDF to parse PDF files and extract text from them. Somewhere in the middle that library does @gzuncompress($text). Problem here is that:

  • nobody knows if text is compressed initially
  • if function returns FALSE (which also triggers a notice) then text is considered to be not compressed and is used as is
  • the error is suppressed by @ (at) operator

The System Log enforces good coding practices by ignoring error suppression and logging that error anyway.

Solution

  1. don't log errors from 3rd party libraries to System Log
  2. log Fatal Error/Exception regardless of their origin
  3. add [suppressed] before error message for errors from In-Portal that developer was trying to suppress

We can filter out non-In-Portal error using following:

  • file path in error is not within FULL_PATH
  • file path in error is within FULL_PATH . '/vendor'
  • file path in error is within FULL_PATH . '/modules', but name of module isn't registered in Modules database table

Related Resources

Related Tasks

INP-1566 - Getting issue details... STATUS

4 Comments

  1. Importance of this has just increased, because in In-Portal 5.3.0 release we're using 3rd-party PHP parser, which triggers "Undefined variable: undefinedVariable" notice on each user. This way the "System Log" can be flooded with easy.

  2. 2. add [suppressed] before error message for errors from In-Portal that developer was trying to suppress

    According to [system log] The silenced errors should not be logged to System Log [5.2.2-B1] the silenced errors won't be logged at all, so no need to prepend "[suppressed]" before it's message.

  3. Another example would be usage of mPDF library (see http://www.mpdf1.com/mpdf/index.php), which due poor code quality triggers thousands of warnings during it's run and basically floods System Log.

  4. Also makes sense to log Fatal Error/Exception regardless of their origin, because it's white screen for end user and we want to know why it happened.