views:

34

answers:

1

When I run php-closure i get a PHP error

Undefined index:  HTTP_IF_NONE_MATCH in <b>/php-closure.php</b> on line <b>183</b>

Line 184 of php-closure is

trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {

This error only happens when closure has already written the compressed javascript file to the directory once, if the directory is emptied the error does not appear. What does this error mean and how can I avoid it?

Thank You So Much!

+2  A: 

This is most likely a negligeable message. The code should check for the presence of HTTP_IF_NONE_MATCH in the server array first, before checking its value. What is set in $_SERVER tends to change from server to server (and the headers sent by the client) so probably the original developer had that value set, and didn't think to check for it.

You could prepend the line in question with a check

if (array_key_exists("HTTP_IF_NONE_MATCH", $_SERVER))

(depending whether the program's logic and flow permit this, of course)

Or turn down the error reporting so that notices are not displayed (not recommended but mybe necessary if you can't touch the package) by putting this into the very beginning of your application:

error_reporting(E_ALL ^ E_NOTICE); 

@Ivo has a great third alternative in his comment.

Pekka
If you don't want to alter the PHP-Closure source code you can put the suggested code before calling the PHP-Closure and initialize the $_SERVER['HTTP_IF_NONE_MATCH'] with some default value.
Ivo Sabev
thanks to both of you for offering a very complete answer : )
Mohammad