Opened 7 years ago

Last modified 7 years ago

#5548 assigned Bug/Something is broken

automated review of php.ini logging settings

Reported by: Ben Dean-Kawamura Owned by: Ben Dean-Kawamura
Priority: Medium Component: Tech
Keywords: php5.4 errors php.ini Cc:
Sensitive: no

Description

We should have a process where we check user's config files and check if they are using the best practices for error/warning logging. In general, this means checking the php.ini file and seeing that warnings are logged to a file, not to a user's database.

Eventually, we should also the config files from drupal and other web apps as well as php.ini.

This was branched out from #5489

Attachments (1)

check-php-code.tar.gz (21.6 KB) - added by Ben Dean-Kawamura 7 years ago.
Script to check

Download all attachments as: .zip

Change History (6)

comment:1 Changed 7 years ago by Ben Dean-Kawamura

One aspect for both this ticket and #5489 is to get a general system for mosh servers to periodically run scripts that check things and report the results.

comment:2 Changed 7 years ago by Ross

Keywords: php5.4 errors php.ini added
Owner: set to Ben Dean-Kawamura
Status: newassigned

comment:3 Changed 7 years ago by Ben Dean-Kawamura

I checked out a couple code checker tools and it looks like PHP-CodeSniffer + "php -l" wil work for us.

PHP-Codesniffer, when using the PHPCompatibility coding standard module, can detect usage of depracated functions and usage of functions in deprecated ways. PHPCompatibility can be found at https://github.com/wimg/PHPCompatibility/.

php -l can be used to find syntax errors. I've seen a bunch of pass-by-reference errors when upgrading PHP. It needs to be used with a php.ini file with the following settings:

  • error_reporting = E_ALL | E_STRICT (report all errors/warnings)
  • display_errors = On (write errors/warnings to stdout)
  • log_errors = Off (Don't write errors/warnings to a file)

comment:4 Changed 7 years ago by Ben Dean-Kawamura

After checkings this more it looks like PHPCompatibility is not going to work. It took over 2 minutes at 99% CPU usage to check drupal's user.module for me. This seems too much to me.

On the simpler side, I checked out the script here: http://www.typofree.org/article/archive/2011/may/title/check-your-php-code-for-deprecated-ini-directives-and-functions/, which just does a bunch of greps. It was fast, but resulted in a bunch of false positives when the functions were mentioned in the comments.

Looks to me like the best we can do is "php -l". We should also probably try to get users to log warnings to files and check those files, but that's a different ticket.

Changed 7 years ago by Ben Dean-Kawamura

Attachment: check-php-code.tar.gz added

Script to check

comment:5 Changed 7 years ago by Ben Dean-Kawamura

Just attached a quick-n-dirty script that checks for errors using php -l and prints them out to stderr.

Please login to add comments to this ticket.

Note: See TracTickets for help on using tickets.