logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: PHP : Undefined variable _GET
Author
dg



Joined: 18 Feb 2016
Posts: 6

PostPosted: Mon 04 Apr '16 16:18    Post subject: PHP : Undefined variable _GET Reply with quote

I got a problem with a php webapplication. It stops working after 10-20 hours (not always the same time) for no reason because $_GET is not defined.

The request looks like:

http://host/index.php?id=1
the index file has a lil code snippet like:

Code:
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = intval($_GET['id']);
} else {
    die('wrong id');
}


A var_dump of $_GET returns NULL. A var_dump of $_SERVER shows the REQUEST_METHOD is GET and the QUERY_STRING is id=1. A var_dump() of $_REQUEST shows id => 1, so it's only $_GET that isn't working.

When that happens it happens for all webapplications on the server and for all users. After restarting the webserver everything is working again for some hours...

System is Windows 2008 R2, Apache 2.4.18 32 Bit/PHP 7.0.5 32 Bit.

No errors inside the php_errors.log, errors.log of httpd or the syslogs.

Configs are pretty much standard.

php.ini:
http://pastebin.com/xhYb0h0n

httpd.conf
http://pastebin.com/YprJjpsW
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Fri 08 Apr '16 17:26    Post subject: Reply with quote

I've tested that and couldn't reproduce that. The only difference is that I don't load the oci8 driver and run PHP over fcgid.

Speaking of fcgid: if you run PHP over that you can define a lifetime ( FcgidProcessLifeTime) and PHP will be restarted without the need of restarting the webserver.
Back to top
dg



Joined: 18 Feb 2016
Posts: 6

PostPosted: Thu 14 Apr '16 10:00    Post subject: Reply with quote

I can't reproduce it either. As I said it just happens after 10-20 hours and I don't know the reason. Logfiles don't show anything.

Had the problem with PHP 7.0.4 and PHP 7.0.5. I'll try to update Apache to 2.4.20 and maybe disable some of the features we are using like mod_deflate.
Back to top
CamaroSS



Joined: 24 Jan 2013
Posts: 78
Location: RF, Tver

PostPosted: Thu 14 Apr '16 16:49    Post subject: Reply with quote

Look for assignments and unset() in your code, maybe the application logic does apply one of those to $_GET under certain conditions. It also may be mistakenly passed by a reference to some functions. There are actually lots of ways, so it's best to check all the usages of $_GET variable.
Back to top
dg



Joined: 18 Feb 2016
Posts: 6

PostPosted: Fri 15 Apr '16 16:01    Post subject: Reply with quote

CamaroSS wrote:
Look for assignments and unset() in your code, maybe the application logic does apply one of those to $_GET under certain conditions. It also may be mistakenly passed by a reference to some functions. There are actually lots of ways, so it's best to check all the usages of $_GET variable.


Was the first thing I checked. Noone manipulated $_GET and no ini_set's either.

Even when I create a file that only has the following code:

Code:
<?php
var_dump($_GET);


I get null when I open that page (index.php?param=test) while $_REQUEST and $_SERVER both show the correct parameters/querystring.
Back to top
unpluggeduk



Joined: 13 Feb 2017
Posts: 1
Location: United Kingdom

PostPosted: Mon 13 Feb '17 14:01    Post subject: Reply with quote

This has been a problem for us as well

It's not just $_GET none of the superglobals seem to be setup.

The heavier the load the worse the problem seems to become.

I have has to resort to putting in code to try and restart Apache when it sees any of the super globals as "Not Set"
Back to top


Reply to topic   Topic: PHP : Undefined variable _GET View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner