[Phpmyadmin-devel] about merging $what and $query_type on libraries/mult_submits.inc.php

Bin Zu xmujay at gmail.com
Tue Sep 17 04:45:32 CEST 2013


Thanks Marc,

>Bin Zu a écrit :
>> Hi Marc,
>> 
>>> Le 2013-09-15 11:38, Bin Zu a écrit :
>>>> Hi Dev,
>>>>
>>>> After the code refactor on libraries/mult_submits.inc.php, we try to merge $what and $query_type on libraries/mult_submits.inc.php
>>>>
>>>> About this issue, I found that :$what and $query_type are used in different branches with different logic.
>>>>
>>>> branch 1 : about $what : 
>>>> https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mult_submits.inc.php#L123
>>>>
>>>> branch 2: about $query_type: 
>>>> https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mult_submits.inc.php#L159
>>>>
>>>> If we merge them together, the two branches should be merged as well. so the logic will be more complicated.
>>>>
>>>>
>>>> What do other guys think?
>>>>
>>>> thanks,
>>>> Bin
>>> Hi Bin,
>>> sorry, I'm not sure I understand your message. My point is that when I
>>> see this:
>>>
>>>
>>> $what = $submit_mult;
>>>
>>> followed a few lines above by
>>>
>>> $query_type = $submit_mult;
>>>
>>> my conclusion is that, maybe, $what and $query_type should be merged.
>> 
>> my meaning is that, 
>> from the code, $what and $query_type are used for different actions.
>> $what: 
>>             case 'add_prefix_tbl':
>>             case 'replace_prefix_tbl':
>>             case 'copy_tbl_change_prefix':
>>             case 'drop_db':
>>             case 'drop_tbl':
>>             case 'empty_tbl':
>>             
>>             
>> $query_type:
>>             case 'check_tbl':
>>             case 'optimize_tbl':
>>             case 'repair_tbl':
>>             case 'analyze_tbl':
>>             ........
>>             
>>             
>>             
>> these two kinds of different actions have different logic of code to hanldle it.
>> branch 1 : about $what : 
>> https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mult_submits.inc.php#L123
>> 
>> branch 2: about $query_type: 
>> https://github.com/phpmyadmin/phpmyadmin/blob/master/libraries/mult_submits.inc.php#L159
>> 
>> 
>> If we merge them together, the two branches should be merged as well. so the logic will be more complicated.
>> so I think the better way is to re-name these two variables to a meanningful name.
>>  
>> what do you think?
>
>Hi Bin,
>It's true that there are many code paths for these.
>
>$query_type should be renamed $action_type (because it's not related to 
>a SQL query).
>
>All actions could be sent to $action_type, and there would be another 
>variable (replacing $what) that indicates whether a confirmation form is 
>required or not.

thanks, I think I can follow this instruction to refactor these two variables. 

thanks,
Bin


More information about the Developers mailing list