[Phpmyadmin-devel] [GSoC2012] Refactoring: Table search, Db search, Multi-table query

Marc Delisle marc at infomarc.info
Fri Apr 6 13:51:31 CEST 2012


Le 2012-04-06 07:38, Ammar Yasir a écrit :
> On Tue, Apr 3, 2012 at 8:23 PM, Marc Delisle <marc at infomarc.info> wrote:
> 
>> Le 2012-04-02 18:39, Ammar Yasir a écrit :
>>> Hi,
>>> Can we have more clarity on improving reference to global variables. Is
>> the
>>> following snippet an example of the same where?
>>> (From tbl_select.php, $_POST parameters are referenced through $GLOBALS)
>>> $post_params = array(
>>>     'ajax_request',
>>>     'collations',
>>>     'db',
>>>     'distinct',
>>>     'fields',
>>>     'func',
>>>     'max_number_of_fields',
>>>     'names',
>>>     'order',
>>>     'orderField',
>>>     'param',
>>>     'session_max_rows',
>>>     'table',
>>>     'types',
>>>     'where',
>>> );
>>> foreach ($post_params as $one_post_param) {
>>>     if (isset($_POST[$one_post_param])) {
>>>         $GLOBALS[$one_post_param] = $_POST[$one_post_param];
>>>     }
>>> }
>>
>> Ammar,
>> this snippet is code added recently, to be able to remove the
>> grab_globals.lib.php library.
>>
>> tbl_select.php uses globals instead of directly referencing
>> $_POST['foo'] so this snippet was a way to keep the script working until
>> better refactoring.
>>
>> However, many scripts are using other global variables as a way to
>> communicate between them or between functions, and we should try to
>> minimize this behavior.
>>
>> Is the use of $sql_query variable as a GET variable for sql.php  an
> example of the same?
> (communication between scripts)

GET and POST variables are always about communication between scripts,
right?

I meant that some functions are either using the global keyword or
$GLOBALS to reach some global variables. Also, procedural code in
included files are using global variables.


-- 
Marc Delisle
http://infomarc.info




More information about the Developers mailing list