Monday, June 25, 2012

GSoC 2012 - 5th Week Progress

      This is the 5th week of my GSoC 2012 project. In last week I started to implement class behavior in common.lib.php file.

       This week I finish remaining part of the implementing class behavior in common.lib.php file. Now the class is named as PMA_CommonFunctions and file is appeared as CommonFunctions.class.php. This class is used singleton pattern to avoid the creation of many objects by several places, which needs more memory. If any function or file with procedural codes contain more than one function inside PMA_CommonFunctions class the class object is assigned to a variable called $common_functions and used that variable to call needed functions inside that class. The classes which use the functions in PMA_CommonFunctions class, were modified by adding getter setter methods to get/set PMA_CommonFunctions class object.

                  I faced several problems while implementing this part. Some functions were used more than 400 times in many files. All of those cannot be just replaced due to some JS functions also appeared with same name. After completing those modifications, I could only see login screen on my browser. After login nothing displayed in my browser. Then according to guidance of Michal, I enabled write error log to file. So that I could debug the code. Then I found that the error was due to calling non-static methods in side static functions in some classes. Those were replaced by direct calling using the static method (PMA_CommonFunctions::getInstance()->someFunction()) instead of get the use of variable for store class instance.

       Then the code was seems work fine. At the moment code is not committed yet due to some conflicts while merging the original PMA code. I'll be able to commit those changes as soon as after resolving them.

            In next week I'll start to looking at the possibility of using PMA_mimeDefaultFunction() function (at the moment this is inside core.lib.php file) inside PMA_DisplayResults class as suggested by Marc. If possible unit tests were implement for the functions inside PMA_DisplayResults class.

Monday, June 18, 2012

GSoC 2012 - 4th Week Progress

      In my third week I introduce a class behavior for display_tbl.lib.php file. Now that file has appeared as DisplayResults.class.php and the class inside it is named as PMA_DisplayResults.

              Since there was a task not completed in last week, I first completed that. It is removing imported super globals from the functions. There were several functions which used local variables which are imported from $GLOBALS super global array. I removed them and directly used super globals where needed. As well for the super globals which were not change during one execution cycle of the PMA code, I assign them to global variables in the PMA_DisplayResults class (local for that class). That global variables are initialized inside constructor.

         As next task, I was moved into fix the bug which was occurred due to breaking _getTableBody() function into subfunctions. It was very helpful for me that Marc had already mentioned the bug is about breaking the feature, which display a link for foreign table value. When I going through the code I saw that was occurred due to incorrect method calling of _getDataCellForNumericFeilds() function (not according to the signature). Now the bug is fixed.

            Then I moved into refactoring common.lib.php file. First I remove the HTML renderings inside the function it selves and return a string instead of that. As well some conventions are used according to my proposal. And the all functions names were modified by removing phrase 'PMA_'.

            Within next week I'm intending to complete implementing class behavior of common.lib.php file. While refactoring DisplayResults.class.php file I have moved a function (PMA_mimeDefaultFunction) to common.lib.php file and now again move it to core.lib.php file for keep it as global function. I intend to again look at the possibility of get that function back to DisplayResults.class.php file.

Tuesday, June 12, 2012

GSoC 2012 - 3rd Week Progress

In my 2nd week, I did some improvements relating to readability and usability of the code including breaking large functions into sub functions. After that step, display_tbl.lib.php file contained many sub functions.

In this week, I mainly focused on applying class behavior to the display_tbl.lib.php file. After getting the confirmation from Michal Čihař for the rough design of that PMA_DisplayResults class, I started my work.

First I search for the functions which are used by the outsiders. There were only two functions (PMA_getTable(), PMA_setConfigParamsForDisplayTable()) were used by sql.php file. Excepting those two functions, private key word was used as access modifier for all other existed functions. For constructor and the above two functions were appeared as public so that any outsider can access those. All existed function names were modified by removing 'PMA_' since they becomes to local functions. The file display_tbl.lib.php was renamed as DisplayResults.class.php .

Then I looked into, remove strings used for conditions in comparisons and introduce constants instead of that. There were many constants after doing this step. If there is any need for change the value of those strings, we can do it by just changing in one place. That is an advantage of using constant.

With these processes there were lots of code violations had been occurred. Most of them were fixed excluding some warnings which were due to very long comparisons inside if conditions.

Introducing global variables for the PMA_DisplayResults class is not finished yet. It will be done in next week. Unexpectedly there was a bug due to one of my previous commits which was pointed by Marc Densile. I am going to fix it in the next week. As well, I'll start to look into refactoring other files related to display query results. Mainly I'll focus on common.lib.php file.