public inbox for gentoo-server@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-server] handling syntax/parse errors with PHP
@ 2007-11-27 17:47 Andrew Gaffney
  2007-11-27 19:16 ` Jil Larner
  2007-11-27 19:24 ` Peter Abrahamsen
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Gaffney @ 2007-11-27 17:47 UTC (permalink / raw
  To: gentoo-server

In my PHP-based websites for work, I have some error handling code that captures 
any errors, displays a "friendly" error page, and then sends me an email with 
all the details about the error.

However, this doesn't work for syntax/parse errors in pages, since the code is 
not actually executed in this case. I can't seem to find anything online about 
capturing these errors and notifying myself somehow.

Does anyone do something like this already?

-- 
Andrew Gaffney                                 http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer             Catalyst/Installer + x86 release coordinator
-- 
gentoo-server@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-server] handling syntax/parse errors with PHP
  2007-11-27 17:47 [gentoo-server] handling syntax/parse errors with PHP Andrew Gaffney
@ 2007-11-27 19:16 ` Jil Larner
  2007-11-27 19:41   ` Brian Kroth
  2007-11-27 19:24 ` Peter Abrahamsen
  1 sibling, 1 reply; 5+ messages in thread
From: Jil Larner @ 2007-11-27 19:16 UTC (permalink / raw
  To: gentoo-server

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

In theory, a production server shouldn't have files with parse errors.
It may be why there's no easy way to handle such an error. So I cannot
give you the way to show a custom error page.
But, for the second point, you may use php.ini' setting like log_errors,
error_log (the logfile path), and ignore_repeated_errors in order to
keep a little file. So you can parse this file and then send a mail, or
whatever you want to do with errors.

I hope it can help you. If you find a way to redirect on such error,
i'll be happy to know how to do ;)

Jil Larner.

Andrew Gaffney a écrit :
> In my PHP-based websites for work, I have some error handling code that
> captures any errors, displays a "friendly" error page, and then sends me
> an email with all the details about the error.
> 
> However, this doesn't work for syntax/parse errors in pages, since the
> code is not actually executed in this case. I can't seem to find
> anything online about capturing these errors and notifying myself somehow.
> 
> Does anyone do something like this already?
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHTG0gMBDlpRaep+4RAjlaAKDa872UZIwZ7SLglKduspga3P7rYACg1jk+
NHCZWsPT5Y2UAJJgk+Gm8Yk=
=qkrR
-----END PGP SIGNATURE-----
-- 
gentoo-server@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-server] handling syntax/parse errors with PHP
  2007-11-27 17:47 [gentoo-server] handling syntax/parse errors with PHP Andrew Gaffney
  2007-11-27 19:16 ` Jil Larner
@ 2007-11-27 19:24 ` Peter Abrahamsen
  2007-11-27 20:11   ` Andrew Gaffney
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Abrahamsen @ 2007-11-27 19:24 UTC (permalink / raw
  To: gentoo-server

Hi Andrew,

I'm not aware of any way to do this. At my last job we focused on
making sure syntax errors never get into the repository, which was
easy to do. We had a pre-commit hook that ran .php files through php
-l (lint mode). If that failed, the commit was rejected. I had another
hook that made sure all the files contained only valid unicode.

I believe there is documentation out there for how to make the hook.

Cheers,
Peter

On Nov 27, 2007 9:47 AM, Andrew Gaffney <agaffney@gentoo.org> wrote:
> In my PHP-based websites for work, I have some error handling code that captures
> any errors, displays a "friendly" error page, and then sends me an email with
> all the details about the error.
>
> However, this doesn't work for syntax/parse errors in pages, since the code is
> not actually executed in this case. I can't seem to find anything online about
> capturing these errors and notifying myself somehow.
>
> Does anyone do something like this already?
>
> --
> Andrew Gaffney                                 http://dev.gentoo.org/~agaffney/
> Gentoo Linux Developer             Catalyst/Installer + x86 release coordinator
> --
> gentoo-server@gentoo.org mailing list
>
>
-- 
gentoo-server@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-server] handling syntax/parse errors with PHP
  2007-11-27 19:16 ` Jil Larner
@ 2007-11-27 19:41   ` Brian Kroth
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Kroth @ 2007-11-27 19:41 UTC (permalink / raw
  To: gentoo-server

[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]

Definitely look at the php.ini.  Also, you might want to have a look at this:

http://www.modsecurity.org/

It has output filtering and a nice set of "Core Rules" that I think might even
have an option for things like this.  There's quite a lot of neat tricks you
can do with it.

Brian

Jil Larner <jil@gnoo.eu>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> 
> In theory, a production server shouldn't have files with parse errors.
> It may be why there's no easy way to handle such an error. So I cannot
> give you the way to show a custom error page.
> But, for the second point, you may use php.ini' setting like log_errors,
> error_log (the logfile path), and ignore_repeated_errors in order to
> keep a little file. So you can parse this file and then send a mail, or
> whatever you want to do with errors.
> 
> I hope it can help you. If you find a way to redirect on such error,
> i'll be happy to know how to do ;)
> 
> Jil Larner.
> 
> Andrew Gaffney a écrit :
> > In my PHP-based websites for work, I have some error handling code that
> > captures any errors, displays a "friendly" error page, and then sends me
> > an email with all the details about the error.
> > 
> > However, this doesn't work for syntax/parse errors in pages, since the
> > code is not actually executed in this case. I can't seem to find
> > anything online about capturing these errors and notifying myself somehow.
> > 
> > Does anyone do something like this already?
> > 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> 
> iD8DBQFHTG0gMBDlpRaep+4RAjlaAKDa872UZIwZ7SLglKduspga3P7rYACg1jk+
> NHCZWsPT5Y2UAJJgk+Gm8Yk=
> =qkrR
> -----END PGP SIGNATURE-----
> -- 
> gentoo-server@gentoo.org mailing list
> 

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 2192 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-server] handling syntax/parse errors with PHP
  2007-11-27 19:24 ` Peter Abrahamsen
@ 2007-11-27 20:11   ` Andrew Gaffney
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Gaffney @ 2007-11-27 20:11 UTC (permalink / raw
  To: gentoo-server

Peter Abrahamsen wrote:
> Hi Andrew,
> 
> I'm not aware of any way to do this. At my last job we focused on
> making sure syntax errors never get into the repository, which was
> easy to do. We had a pre-commit hook that ran .php files through php
> -l (lint mode). If that failed, the commit was rejected. I had another
> hook that made sure all the files contained only valid unicode.

That actually does help me some. I didn't know about php's lint mode. I ran it 
on all the .php files in this particular site ("find /var/www/<domain>/htdocs 
-name '*.php' -exec php -l {} \;" for anyone that's curious) and didn't come up 
with anything.

This all started when one of our order takers told me they got a call from 
someone who said they got a parse error on our site, but I didn't have any more 
information than that. I clicked around, but didn't hit any problems.

I still don't see any problems, but at least now I have peace of mind :)

-- 
Andrew Gaffney                                 http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer             Catalyst/Installer + x86 release coordinator
-- 
gentoo-server@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-27 20:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-27 17:47 [gentoo-server] handling syntax/parse errors with PHP Andrew Gaffney
2007-11-27 19:16 ` Jil Larner
2007-11-27 19:41   ` Brian Kroth
2007-11-27 19:24 ` Peter Abrahamsen
2007-11-27 20:11   ` Andrew Gaffney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox