Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making code work with register_globals turned off

I have inherited some legacy PHP code what was written back when it was standard practice to use register_globals (As of PHP 4.2.0, this directive defaults to off, released 22. Apr 2002).

We know now that it is bad for security to have it enabled. The problem is how do I find all the places in the code where I need to use $_GET or $_POST? My only thought was to set the error reporting to warn about uninitialized variables and then test each part of the site. Is there an easier way? Will I have to test each code path in the site or will PHP give a warning on a file basis?

like image 677
ejunker Avatar asked Aug 09 '08 05:08

ejunker


1 Answers

If you set error reporting to E_ALL, it warns in the error log about undefined variables complete with filename and line number (assuming you are logging to a file). However, it will warn only if when it comes across an undefined variable, so I think you will have to test each code path. Running php from the command line doesn't seem to help also.

There is a debugging tool named xdebug, haven't tried it, but maybe that can be useful?

like image 157
Marie Fischer Avatar answered Sep 21 '22 21:09

Marie Fischer