[Phpmyadmin-devel] Refactoring: Displaying query results

Hi All, I have a doubt of using *@see* tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ? Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using *@see* tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All, I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what would be the better approach ? Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code } Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ? Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Le 2012-06-09 15:44, Chanaka Dharmarathna a écrit :
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using *@see* tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what would be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
Regards !
Chanaka, what kind of code violation is it? A line too long? If it's the case, well we should adjust our violations tests because for me, introducing an unneeded temporary variable just for that would reduce readability. -- Marc Delisle http://infomarc.info

On Sun, Jun 10, 2012 at 5:02 AM, Marc Delisle <marc@infomarc.info> wrote:
Le 2012-06-09 15:44, Chanaka Dharmarathna a écrit :
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using *@see* tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what would be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
Regards !
Chanaka, what kind of code violation is it? A line too long?
If it's the case, well we should adjust our violations tests because for me, introducing an unneeded temporary variable just for that would reduce readability.
-- Marc Delisle http://infomarc.info
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc, Thanks for replying. Yes, code sniffer gives warning saying line is too long. I also feel its not a good idea to use temporary variable if only it is not used couple of time. Shall we define convention for this kind of scenario so that everywhere handle this kind of situation in same way. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

2012/6/9 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using @see tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what would be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
It depends : If the value of $_SESSION['tmp_user_values']['display_text'] is used later on in the code, you could assign it to a shorter local (temporary) variable, and use that variable with a shorter name, in the if statement and further on in the code. If it is used only oncet you might consider assigning the result of $_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT to a local (temporary) variable and use that variable in the if statement. Hope this helps! -- Kind regards, Dieter Adriaenssens

On Sun, Jun 10, 2012 at 11:21 PM, Dieter Adriaenssens < dieter.adriaenssens@gmail.com> wrote:
2012/6/9 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using @see tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what
would
be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
It depends :
If the value of $_SESSION['tmp_user_values']['display_text'] is used later on in the code, you could assign it to a shorter local (temporary) variable, and use that variable with a shorter name, in the if statement and further on in the code.
If it is used only oncet you might consider assigning the result of
$_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT
to a local (temporary) variable and use that variable in the if statement.
Hope this helps!
-- Kind regards,
Dieter Adriaenssens
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Dieter, Thanks for your reply. I agreed your first point. But I feels little odd in the second point because only for one place we use an additional variable. Its better if we can put that kind of conditions to two lines. Currently it gives errors by code sniffer. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

I NEED TO REDIRECT MY WEBSITE.... HOW AND WHERE CAN I DO THAT???? From: Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> To: phpmyadmin-devel@lists.sourceforge.net Sent: Monday, June 11, 2012 4:02 PM Subject: Re: [Phpmyadmin-devel] Refactoring: Displaying query results On Sun, Jun 10, 2012 at 11:21 PM, Dieter Adriaenssens <dieter.adriaenssens@gmail.com> wrote: 2012/6/9 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using @see tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what would be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
It depends :
If the value of $_SESSION['tmp_user_values']['display_text'] is used later on in the code, you could assign it to a shorter local (temporary) variable, and use that variable with a shorter name, in the if statement and further on in the code.
If it is used only oncet you might consider assigning the result of
$_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT
to a local (temporary) variable and use that variable in the if statement.
Hope this helps!
-- Kind regards,
Dieter Adriaenssens
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Dieter, Thanks for your reply. I agreed your first point. But I feels little odd in the second point because only for one place we use an additional variable. Its better if we can put that kind of conditions to two lines. Currently it gives errors by code sniffer. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel

Le 2012-06-11 16:26, Maria Medina a écrit :
I NEED TO REDIRECT MY WEBSITE.... HOW AND WHERE CAN I DO THAT????
You could contact your web host provider, not this list. -- Marc Delisle http://infomarc.info

On Tue, Jun 12, 2012 at 1:32 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 10, 2012 at 11:21 PM, Dieter Adriaenssens < dieter.adriaenssens@gmail.com> wrote:
2012/6/9 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using @see tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what
would
be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
It depends :
If the value of $_SESSION['tmp_user_values']['display_text'] is used later on in the code, you could assign it to a shorter local (temporary) variable, and use that variable with a shorter name, in the if statement and further on in the code.
If it is used only oncet you might consider assigning the result of
$_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT
to a local (temporary) variable and use that variable in the if statement.
Hope this helps!
-- Kind regards,
Dieter Adriaenssens
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Dieter,
Thanks for your reply. I agreed your first point. But I feels little odd in the second point because only for one place we use an additional variable. Its better if we can put that kind of conditions to two lines. Currently it gives errors by code sniffer.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal, I'll moving into refactoring common.lib.php file. I'm intending to use the same improvements for this file as DisplayResults.class.php , including creating common.lib.php as a class. Is there any suggestions from your side ? Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Thu, Jun 14, 2012 at 12:58 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
On Tue, Jun 12, 2012 at 1:32 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 10, 2012 at 11:21 PM, Dieter Adriaenssens < dieter.adriaenssens@gmail.com> wrote:
2012/6/9 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
On Fri, Jun 8, 2012 at 10:58 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
Hi All,
I have a doubt of using @see tag in Docblock comments for functions. In the comments of functions PMA_getTable() and PMA_getTableBody() in display_tbl.lib.php file, @see tag is used for different purposes. As I feel PMA_getTableBody() used that corrrectly. What should be the actual behavior ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All,
I am fixing some code violations in my code now. For remove code violation of large comparison in a if condition, what
would
be the better approach ?
Ex:- if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars']) && ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT) ) { // code }
Is that good to use tempory variable insted of using $_SESSION['tmp_user_values']['display_text'] ?
It depends :
If the value of $_SESSION['tmp_user_values']['display_text'] is used later on in the code, you could assign it to a shorter local (temporary) variable, and use that variable with a shorter name, in the if statement and further on in the code.
If it is used only oncet you might consider assigning the result of
$_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT
to a local (temporary) variable and use that variable in the if statement.
Hope this helps!
-- Kind regards,
Dieter Adriaenssens
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Dieter,
Thanks for your reply. I agreed your first point. But I feels little odd in the second point because only for one place we use an additional variable. Its better if we can put that kind of conditions to two lines. Currently it gives errors by code sniffer.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal,
I'll moving into refactoring common.lib.php file. I'm intending to use the same improvements for this file as DisplayResults.class.php , including creating common.lib.php as a class. Is there any suggestions from your side ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi All, I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters); I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php. Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction(). Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right? -- Marc Delisle http://infomarc.info

On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle <marc@infomarc.info> wrote:
Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
-- Marc Delisle http://infomarc.info
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc, Sorry for little bit delay to respond. I first try to use this function while it is inside the PMA_DisplayResults class. But if there is any field with transformations, it does not work properly. So that put it as a global function. But I can again consider on that after completing the implement class behavior of common.lib.php file For just now I move PMA_mimeDefaultFunction() function to core.lib.php file. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Mon, Jun 18, 2012 at 6:36 PM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle <marc@infomarc.info> wrote:
Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
-- Marc Delisle http://infomarc.info
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc,
Sorry for little bit delay to respond. I first try to use this function while it is inside the PMA_DisplayResults class. But if there is any field with transformations, it does not work properly.
So that put it as a global function. But I can again consider on that after completing the implement class behavior of common.lib.php file For just now I move PMA_mimeDefaultFunction() function to core.lib.php file.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal, There are many places which are using functions in common.lib.php file. After implement the class behavior for this file, all the other places need to call those functions using an object of PMA_CommonFunctions class. Even in the same file I may need to create several objects of the PMA_CommonFunctions class. (files with global functions) So I' thinking of using global variable (in $GLOBALS super global array) to store an object of PMA_CommonFunctions class and introduce a global function (may be under core.lib.php) to get that object by checking whether the global variable is set or not. So that even inside the procedural code segments, that function can be used. Its highly appreciated if you can give me your feedback on this approach. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On 19/06/12 09:35, Chanaka Dharmarathna wrote:
On Mon, Jun 18, 2012 at 6:36 PM, Chanaka Dharmarathna< pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle<marc@infomarc.info> wrote:
Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
-- Marc Delisle http://infomarc.info
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc,
Sorry for little bit delay to respond. I first try to use this function while it is inside the PMA_DisplayResults class. But if there is any field with transformations, it does not work properly.
So that put it as a global function. But I can again consider on that after completing the implement class behavior of common.lib.php file For just now I move PMA_mimeDefaultFunction() function to core.lib.php file.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal,
There are many places which are using functions in common.lib.php file. After implement the class behavior for this file, all the other places need to call those functions using an object of PMA_CommonFunctions class. Even in the same file I may need to create several objects of the PMA_CommonFunctions class. (files with global functions)
So I' thinking of using global variable (in $GLOBALS super global array) to store an object of PMA_CommonFunctions class and introduce a global function (may be under core.lib.php) to get that object by checking whether the global variable is set or not. So that even inside the procedural code segments, that function can be used. Its highly appreciated if you can give me your feedback on this approach.
Regards !
What you seem to want is a singleton [0]. In a few words: the constructor is private, the instance is in a static variable and a public getInstance method allows access to the instance. You can also have a look at the PMA_Response class for a concrete example. Bye, Rouslan [0]: http://en.wikipedia.org/wiki/Singleton_pattern

On Tue, Jun 19, 2012 at 2:37 PM, Rouslan Placella <rouslan@placella.com>wrote:
On 19/06/12 09:35, Chanaka Dharmarathna wrote:
On Mon, Jun 18, 2012 at 6:36 PM, Chanaka Dharmarathna< pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle<marc@infomarc.info>
wrote:
Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php
(in
master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
-- Marc Delisle http://infomarc.info
Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc,
Sorry for little bit delay to respond. I first try to use this function while it is inside the PMA_DisplayResults class. But if there is any field with transformations, it does not work properly.
So that put it as a global function. But I can again consider on that after completing the implement class behavior of common.lib.php file For just now I move PMA_mimeDefaultFunction() function to core.lib.php file.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal,
There are many places which are using functions in common.lib.php file. After implement the class behavior for this file, all the other places need to call those functions using an object of PMA_CommonFunctions class. Even in the same file I may need to create several objects of the PMA_CommonFunctions class. (files with global functions)
So I' thinking of using global variable (in $GLOBALS super global array) to store an object of PMA_CommonFunctions class and introduce a global function (may be under core.lib.php) to get that object by checking whether the global variable is set or not. So that even inside the procedural code segments, that function can be used. Its highly appreciated if you can give me your feedback on this approach.
Regards !
What you seem to want is a singleton [0]. In a few words: the constructor is private, the instance is in a static variable and a public getInstance method allows access to the instance. You can also have a look at the PMA_Response class for a concrete example.
Bye, Rouslan
[0]: http://en.wikipedia.org/wiki/Singleton_pattern
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Rouslan, Thanks for your quick and valuable information. Singleton pattern definitely use only one object and it save the memory. I'll use that. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Tue, Jun 19, 2012 at 3:23 PM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
On Tue, Jun 19, 2012 at 2:37 PM, Rouslan Placella <rouslan@placella.com>wrote:
On 19/06/12 09:35, Chanaka Dharmarathna wrote:
On Mon, Jun 18, 2012 at 6:36 PM, Chanaka Dharmarathna< pe.chanaka.ck@gmail.com> wrote:
On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle<marc@infomarc.info>
wrote:
Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php
(in
master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
-- Marc Delisle http://infomarc.info
Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Marc,
Sorry for little bit delay to respond. I first try to use this function while it is inside the PMA_DisplayResults class. But if there is any field with transformations, it does not work properly.
So that put it as a global function. But I can again consider on that after completing the implement class behavior of common.lib.php file For just now I move PMA_mimeDefaultFunction() function to core.lib.php file.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal,
There are many places which are using functions in common.lib.php file. After implement the class behavior for this file, all the other places need to call those functions using an object of PMA_CommonFunctions class. Even in the same file I may need to create several objects of the PMA_CommonFunctions class. (files with global functions)
So I' thinking of using global variable (in $GLOBALS super global array) to store an object of PMA_CommonFunctions class and introduce a global function (may be under core.lib.php) to get that object by checking whether the global variable is set or not. So that even inside the procedural code segments, that function can be used. Its highly appreciated if you can give me your feedback on this approach.
Regards !
What you seem to want is a singleton [0]. In a few words: the constructor is private, the instance is in a static variable and a public getInstance method allows access to the instance. You can also have a look at the PMA_Response class for a concrete example.
Bye, Rouslan
[0]: http://en.wikipedia.org/wiki/Singleton_pattern
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Rouslan,
Thanks for your quick and valuable information. Singleton pattern definitely use only one object and it save the memory. I'll use that.
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
Hi Michal, I almost did the modifications related to introduce class behavior of common.lib.php file. It is quite time consuming task since there are lot of files to do the minor modifications. Now I'm facing to a problem. Due to this changes code has not working properly. (I didn't commit the code yet since it is not working) Is there any log file or something where we can see code is breaking? Since this is not just one file its very hard to find out the errors. Looking for suggestions to debug this code. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi First comment: Please try to remove useless previous discussion when posting new email. Dne Fri, 22 Jun 2012 00:57:35 +0530 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> napsal(a):
I almost did the modifications related to introduce class behavior of common.lib.php file. It is quite time consuming task since there are lot of files to do the minor modifications.
Indeed, it will take some time.
Now I'm facing to a problem. Due to this changes code has not working properly. (I didn't commit the code yet since it is not working) Is there any log file or something where we can see code is breaking? Since this is not just one file its very hard to find out the errors. Looking for suggestions to debug this code.
What kind of error do you get? Do you have enabled gathering and displaying of errors [1]? [1]: http://wiki.phpmyadmin.net/pma/Config#Error_Handler -- Michal Čihař | http://cihar.com | http://blog.cihar.com

Hi Michal, First comment: Please try to remove useless previous discussion when
posting new email.
Sure, I'll follow your instructions.
What kind of error do you get? Do you have enabled gathering and displaying of errors [1]?
[1]: http://wiki.phpmyadmin.net/pma/Confi<http://wiki.phpmyadmin.net/pma/Config#Error_Handler>
Actually I got nothing after login to PMA. I had only enabled display errors but not others. But now I am debugging the error points after following suggested link. Thanks for your great guide. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
Hi Marc, I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way) Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes. And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows. $class_name = 'TestClass'; $ob = new $class_name($params); It is very helpful for me if you can share your suggestions. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Le 2012-06-27 22:04, Chanaka Dharmarathna a écrit :
Hi All,
I have already create a class for display_tbl.lib.php andPMA_getDataCellForBlobField() in master used the PMA_mimeDefaultFunction() function as a global function. EX : $str = 'PMA_mimeDefaultFunction'; $str($parameters);
I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in master) to common.lib.php file due to the way it has used inside display_tbl.lib.php.
Now I'm implementing class behavior in common.lib.php file. So can anyone tell me a file, which contain global function, to where I should again move this PMA_mimeDefaultFunction().
Regards !
Chanaka, I believe that this function should not be global, as it's only called from other functions in libraries/DisplayResults.class.php, right?
Hi Marc,
I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way)
Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes.
And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows.
$class_name = 'TestClass'; $ob = new $class_name($params);
It is very helpful for me if you can share your suggestions.
Regards !
Hi Chanaka, maybe others, especially Alex Marin, would have an idea to share with you. I have not yet studied his new plugin system for transformations. -- Marc Delisle http://infomarc.info

Hi Chanaka, On Thu, Jun 28, 2012 at 5:04 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way)
Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes.
I've seen that the PMA_mimeDefaultFunction is only currently used in DisplayResults.class.php, so I think it's a good idea to move it there.
And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows.
$class_name = 'TestClass'; $ob = new $class_name($params);
It is very helpful for me if you can share your suggestions.
As general info, to use a transformation plugin, you have to include it and then instantiate it. For example, if you want to use Text_Plain_Sql: include_once 'libraries/plugins/transformations/Text_Plain_Sql.class.php'; $plugin_manager = null; // Still working on this, so you can use null for now $sql_transf = new Text_Plain_Sql($plugin_manager); Then, you can use the actual transformation by calling: $sql_transf->applyTransformation(); In DisplayResults.class.php, inside _getTableBody(), there is an init: [2158] $default_function = 'PMA_mimeDefaultFunction'; // default_function Then, this variable is passed as an argument to several functions along the way: _getDataCellForNumericColumns, _getDataCellForBlobColumns, _getDataCellForGeometryColumns, _getDataCellForNonNumericAndNonBlobColumns, _getRowData, _addClass _handleNonPrintableContents Some of the functions only pass it further, while others use actually use it. I replaced the use of the PMA_transformation_[FILENAME]() with the use of $transformation_plugin->applyTransformation() and kept the same arguments. So I had to pass an instance of the transformation class as an argument ($transformation_plugin), but my problem was that in some cases I had to use the applyTransformations method, while in others, I had to use the default function ( PMA_mimeDefaultFunction() ). Therefore, where needed, I set the argument $transformation_plugin = $default_function, and, in the above mentioned methods I checked and used accordingly, something similar to: $result = ($transformation_plugin != $default_function ? $transformation_plugin->applyTransformation( $data, $transform_options, $meta ) : $default_function($data) ) Hope that helps. I will write some wikis for all of the plugins, but I thought I should first finish the whole system (the plugin managers). -- Alex

Hi Alex, Sorry for posting top post, but I'm just reading up on some mails on my phone while waiting for the intermission to end. Just an idea, while reading your description of how to use the transformation classes : why don't you provide a factory pattern to instantiate/create the classes. Everything like checking if the include file exists, including it and preparing/instantiating can be done in the factory. Also consider creating an interface for every type of class (auth, export/import, transformation, ...) and implement it in every derived class (f.e. ExportSql, ExportXml could implement a ExportInterface) Kind regards, Dieter Adriaenssens. Op 28 jun. 2012 18:08 schreef "Alex Marin" <alex.ukf@gmail.com> het volgende:
Hi Chanaka,
On Thu, Jun 28, 2012 at 5:04 AM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:
I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way)
Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes.
I've seen that the PMA_mimeDefaultFunction is only currently used in DisplayResults.class.php, so I think it's a good idea to move it there.
And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows.
$class_name = 'TestClass'; $ob = new $class_name($params);
It is very helpful for me if you can share your suggestions.
As general info, to use a transformation plugin, you have to include it and then instantiate it. For example, if you want to use Text_Plain_Sql: include_once 'libraries/plugins/transformations/Text_Plain_Sql.class.php'; $plugin_manager = null; // Still working on this, so you can use null for now $sql_transf = new Text_Plain_Sql($plugin_manager); Then, you can use the actual transformation by calling: $sql_transf->applyTransformation();
In DisplayResults.class.php, inside _getTableBody(), there is an init: [2158] $default_function = 'PMA_mimeDefaultFunction'; // default_function Then, this variable is passed as an argument to several functions along the way: _getDataCellForNumericColumns, _getDataCellForBlobColumns, _getDataCellForGeometryColumns, _getDataCellForNonNumericAndNonBlobColumns, _getRowData, _addClass _handleNonPrintableContents
Some of the functions only pass it further, while others use actually use it. I replaced the use of the PMA_transformation_[FILENAME]() with the use of $transformation_plugin->applyTransformation() and kept the same arguments. So I had to pass an instance of the transformation class as an argument ($transformation_plugin), but my problem was that in some cases I had to use the applyTransformations method, while in others, I had to use the default function ( PMA_mimeDefaultFunction() ). Therefore, where needed, I set the argument $transformation_plugin = $default_function, and, in the above mentioned methods I checked and used accordingly, something similar to: $result = ($transformation_plugin != $default_function ? $transformation_plugin->applyTransformation( $data, $transform_options, $meta ) : $default_function($data) )
Hope that helps. I will write some wikis for all of the plugins, but I thought I should first finish the whole system (the plugin managers).
-- Alex
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel

On Thu, Jun 28, 2012 at 11:38 PM, Dieter Adriaenssens <dieter.adriaenssens@gmail.com> wrote:
Just an idea, while reading your description of how to use the transformation classes : why don't you provide a factory pattern to instantiate/create the classes. Everything like checking if the include file exists, including it and preparing/instantiating can be done in the factory.
That sounds like a good idea.
Also consider creating an interface for every type of class (auth, export/import, transformation, ...) and implement it in every derived class (f.e. ExportSql, ExportXml could implement a ExportInterface)
Currently, this is implemented with abstract classes (f.e. ExportSql and ExportXml extend ExportPlugin and so on), and those provide a similar functionality to the interface. I decided to use abstract classes, because I wanted to be able to declare some common variables and getters and setters for them. -- Alex

2012/6/29 Alex Marin <alex.ukf@gmail.com>:
On Thu, Jun 28, 2012 at 11:38 PM, Dieter Adriaenssens <dieter.adriaenssens@gmail.com> wrote:
Just an idea, while reading your description of how to use the transformation classes : why don't you provide a factory pattern to instantiate/create the classes. Everything like checking if the include file exists, including it and preparing/instantiating can be done in the factory.
That sounds like a good idea.
Also consider creating an interface for every type of class (auth, export/import, transformation, ...) and implement it in every derived class (f.e. ExportSql, ExportXml could implement a ExportInterface)
Currently, this is implemented with abstract classes (f.e. ExportSql and ExportXml extend ExportPlugin and so on), and those provide a similar functionality to the interface. I decided to use abstract classes, because I wanted to be able to declare some common variables and getters and setters for them.
Hi Alex, Good thinking! :) Deriving your actual classes from a common abstract class is the best way to do this, adding an interface is optional because the necessary public classes are probably already defined in your abstract class, but it's a good practise to provide an interface. ;) -- Kind regards, Dieter Adriaenssens

I'm going to look into getting PMA_mimeDefaultFunction() function inside PMA_DisplayResults class. (currently it is under core.lib.php) I think it is possible to use this function inside that class, and call directly ($this->_mimeDefaultFunction()) instead of using additional string to store method name. (current way)
Then the default function for the mime transformation is inside a class. But the other existing transformations functions are still global functions. If that is not good (feels not good), those also should convert to classes.
I've seen that the PMA_mimeDefaultFunction is only currently used in DisplayResults.class.php, so I think it's a good idea to move it there.
And if other transformations converted to classes, in which way I can create objects of those classes. Should I need to use string to store the class name and then use it as belows.
$class_name = 'TestClass'; $ob = new $class_name($params);
It is very helpful for me if you can share your suggestions.
As general info, to use a transformation plugin, you have to include it and then instantiate it. For example, if you want to use Text_Plain_Sql: include_once 'libraries/plugins/transformations/Text_Plain_Sql.class.php'; $plugin_manager = null; // Still working on this, so you can use null for now $sql_transf = new Text_Plain_Sql($plugin_manager); Then, you can use the actual transformation by calling: $sql_transf->applyTransformation();
In DisplayResults.class.php, inside _getTableBody(), there is an init: [2158] $default_function = 'PMA_mimeDefaultFunction'; // default_function Then, this variable is passed as an argument to several functions along the way: _getDataCellForNumericColumns, _getDataCellForBlobColumns, _getDataCellForGeometryColumns, _getDataCellForNonNumericAndNonBlobColumns, _getRowData, _addClass _handleNonPrintableContents
Some of the functions only pass it further, while others use actually use it. I replaced the use of the PMA_transformation_[FILENAME]() with the use of $transformation_plugin->applyTransformation() and kept the same arguments. So I had to pass an instance of the transformation class as an argument ($transformation_plugin), but my problem was that in some cases I had to use the applyTransformations method, while in others, I had to use the default function ( PMA_mimeDefaultFunction() ). Therefore, where needed, I set the argument $transformation_plugin = $default_function, and, in the above mentioned methods I checked and used accordingly, something similar to: $result = ($transformation_plugin != $default_function ? $transformation_plugin->applyTransformation( $data, $transform_options, $meta ) : $default_function($data) )
Hope that helps. I will write some wikis for all of the plugins, but I thought I should first finish the whole system (the plugin managers).
Hi Alex, Thanks for sharing your ideas on this. These days I'm getting many conflicts due to modifying common.lib.php file. Same thing happens again after merging master. Is there any possibility that you need to use default mime function outside the PMA_DisplayResults class ? Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi Alex,
Is there any possibility that you need to use default mime function outside
the PMA_DisplayResults class ?
Right now, I can't see any use for it in some other place.
Fine. :)
Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi Michal, I have merged the current master and commit it to my forked copy. It contains the class behavior of the common.lib.php file in addition to the changes in current master. But there are several known issues. 1. While browse tables with JPEG or PNG mime types I get following warning, Warning in ./libraries/DisplayResults.class.php#4582 strpos() expects parameter 1 to be string, object given 2. When the session expires, after click logout I get following notice, Notice in ./libraries/relation.lib.php#35 Undefined index: controllink 3. When incorrect login, following warning raised, *Warning* in ./libraries/dbi/mysqli.dbi.lib.php#97 mysqli_real_connect(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) 4. When insert data for any table, after click Go button, it shows the SQL window. (should redirect to Browse window) Can you please verify that current master have any of this issues or not. And if those are not because of my commits, I think its ready to merge my code to master. Otherwise I could resolve more and more conflicts as same as these days :) Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Sat, Jun 30, 2012 at 12:39 PM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi Michal,
I have merged the current master and commit it to my forked copy. It contains the class behavior of the common.lib.php file in addition to the changes in current master.
But there are several known issues. 1. While browse tables with JPEG or PNG mime types I get following warning, Warning in ./libraries/DisplayResults.class.php#4582 strpos() expects parameter 1 to be string, object given
2. When the session expires, after click logout I get following notice, Notice in ./libraries/relation.lib.php#35 Undefined index: controllink
3. When incorrect login, following warning raised, *Warning* in ./libraries/dbi/mysqli.dbi.lib.php#97 mysqli_real_connect(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES)
4. When insert data for any table, after click Go button, it shows the SQL window. (should redirect to Browse window)
Can you please verify that current master have any of this issues or not. And if those are not because of my commits, I think its ready to merge my code to master. Otherwise I could resolve more and more conflicts as same as these days :)
Hi Michal, Only the issue 1 has corrected in the master. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi Dne Sat, 30 Jun 2012 12:39:33 +0530 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> napsal(a):
I have merged the current master and commit it to my forked copy.
It looks like you did something wrong as you've reintroduced files which were deleted in master.
It contains the class behavior of the common.lib.php file in addition to the changes in current master.
But there are several known issues. 1. While browse tables with JPEG or PNG mime types I get following warning, Warning in ./libraries/DisplayResults.class.php#4582 strpos() expects parameter 1 to be string, object given
AFAIK already fixed in master.
2. When the session expires, after click logout I get following notice, Notice in ./libraries/relation.lib.php#35 Undefined index: controllink
Probably a bug, not necessarily in your changes.
3. When incorrect login, following warning raised, *Warning* in ./libraries/dbi/mysqli.dbi.lib.php#97 mysqli_real_connect(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES)
This is correct.
4. When insert data for any table, after click Go button, it shows the SQL window. (should redirect to Browse window)
Probably not related to your changes. -- Michal Čihař | http://cihar.com | http://phpmyadmin.cz

Hi Michal, It looks like you did something wrong as you've reintroduced files
which were deleted in master.
You are correct, Its my mistake while I'm messed up with resolving conflicts. Sorry for that and thanks for pointing that I just corrected them. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Le 2012-06-30 10:59, Michal Čihař a écrit :
Hi
Dne Sat, 30 Jun 2012 12:39:33 +0530 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> napsal(a):
4. When insert data for any table, after click Go button, it shows the SQL window. (should redirect to Browse window)
Probably not related to your changes.
This is fixed now. -- Marc Delisle http://infomarc.info

Hi Michal, I'm going to improve test cases for PMA_DisplayResults class. I saw some test cases has already implemented by Yasitha. I'll implement tests for remaining functions. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi Michal, I almost reduce the use of super global variables inside functions of PMA_DisplayResults class. Most of the fields are set while executing the getTable() function since they cannot set while executing the constructor. Now I'm move into writing tests. I am facing to a problem with writing tests. How can I access or set the private variables, by a test ? The already existed tests also failing due to this change. Your suggestions will very helpful. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

2012/7/7 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
Hi Michal,
I almost reduce the use of super global variables inside functions of PMA_DisplayResults class. Most of the fields are set while executing the getTable() function since they cannot set while executing the constructor.
Now I'm move into writing tests. I am facing to a problem with writing tests. How can I access or set the private variables, by a test ? The already existed tests also failing due to this change. Your suggestions will very helpful.
Hi Chanaka, I didn't have a look at the current tests and at PMA_DisplayResults class, so I won't be able to go into specifics about your tests, but I will try to answer your questions, and point you in a direction. Accessing or setting private variables in a class/method is not possible during a unit test. The idea of unit tests is to test the functionality of a class method or global function by testing the output of it, or catching errors. You expect a certain behaviour of the method/function depending on the value of the input parameters (or environmental states, like global variables, database content, or config settings). So basically you think of all different situations that can affect the behaviour of the method/function, define what kind of result this would give and write a test that sets up the situation and test (assert) the output of the function/method. When writing unit tests, you should keep in mind that you are only testing the behaviour of that function/method. Any functions/methods used by a function/method should be tested seperately. By which I mean that you must assume when testing a function/method that the functions/methods that are used in that method, work correctly. To make things easier for you, you can define stubs/mocks [0] that replace the methods/functions used in a function/method you are testing. This way you don't have to set up a complete environment, but can concentrate on what the function/method does. As an example If you have a class that gets values from a database : class DbValues { private $_values; __construct() { $this->_values = array(); } public function getValuesFromDb() { // functionality making a connection to a database, executing a query and setting the resulting values to $_values. } public function getValues() { return $this->_values; } public function count() { return count($this->getValues()); } } And you want to test the behaviour of the count() method. The only way to populate the _values variable in this example would be by setting up a database with different sets of values, for each case you want to test and call the getValuesFromDb() method, OR, you can define a stub that replaces the getValues() method and let it return an array with the necessary amount of values (depending on what you want to test). This way you avoid having to set up a complicated testing environment, when testing a single class method. (Note : when testing the getValuesFromDb() method you will probably have to set up a database, but that's because that method is all about connecting to a database and getting data from it, but all other methods in this class can assume that the getValuesFromDb works, so there is no need to replicate the complicated test environment every time) I suggest you read up a bit on testing class methods and the use of stubs/mocks. I hope my example didn't confuse you too much. [0] http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs Kind regards, Dieter
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
-- Kind regards, Dieter Adriaenssens

Hi Dieter,
I almost reduce the use of super global variables inside functions of
PMA_DisplayResults class. Most of the fields are set while executing the getTable() function since they cannot set while executing the constructor.
Now I'm move into writing tests. I am facing to a problem with writing tests. How can I access or set the private variables, by a test ? The already existed tests also failing due to this change. Your suggestions will very helpful.
I didn't have a look at the current tests and at PMA_DisplayResults class, so I won't be able to go into specifics about your tests, but I will try to answer your questions, and point you in a direction.
Accessing or setting private variables in a class/method is not possible during a unit test. The idea of unit tests is to test the functionality of a class method or global function by testing the output of it, or catching errors. You expect a certain behaviour of the method/function depending on the value of the input parameters (or environmental states, like global variables, database content, or config settings). So basically you think of all different situations that can affect the behaviour of the method/function, define what kind of result this would give and write a test that sets up the situation and test (assert) the output of the function/method.
When writing unit tests, you should keep in mind that you are only testing the behaviour of that function/method. Any functions/methods used by a function/method should be tested seperately. By which I mean that you must assume when testing a function/method that the functions/methods that are used in that method, work correctly. To make things easier for you, you can define stubs/mocks [0] that replace the methods/functions used in a function/method you are testing. This way you don't have to set up a complete environment, but can concentrate on what the function/method does.
As an example
If you have a class that gets values from a database :
class DbValues { private $_values;
__construct() { $this->_values = array(); }
public function getValuesFromDb() { // functionality making a connection to a database, executing a query and setting the resulting values to $_values. }
public function getValues() { return $this->_values; }
public function count() { return count($this->getValues()); } }
And you want to test the behaviour of the count() method. The only way to populate the _values variable in this example would be by setting up a database with different sets of values, for each case you want to test and call the getValuesFromDb() method, OR, you can define a stub that replaces the getValues() method and let it return an array with the necessary amount of values (depending on what you want to test). This way you avoid having to set up a complicated testing environment, when testing a single class method. (Note : when testing the getValuesFromDb() method you will probably have to set up a database, but that's because that method is all about connecting to a database and getting data from it, but all other methods in this class can assume that the getValuesFromDb works, so there is no need to replicate the complicated test environment every time)
I suggest you read up a bit on testing class methods and the use of stubs/mocks. I hope my example didn't confuse you too much.
[0] http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs
Thank you very much for spending your time for clarify this with valuable and enough information. I completely agree with you, on writing unit tests independent/separate from another layer/function. Mock objects/stubs are helpful in that case. At the moment there are around 25 private fields in PMA_DisplayResults class. What I am thinking of implement getter setter methods for all those and use getters and setters where needed. In that way I will be able to set those private fields even from the tests. What do you think on this ? Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

On Sat, Jul 7, 2012 at 8:00 PM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
Hi Dieter,
I almost reduce the use of super global variables inside functions of
PMA_DisplayResults class. Most of the fields are set while executing the getTable() function since they cannot set while executing the constructor.
Now I'm move into writing tests. I am facing to a problem with writing tests. How can I access or set the private variables, by a test ? The already existed tests also failing due to this change. Your suggestions will very helpful.
I didn't have a look at the current tests and at PMA_DisplayResults class, so I won't be able to go into specifics about your tests, but I will try to answer your questions, and point you in a direction.
Accessing or setting private variables in a class/method is not possible during a unit test. The idea of unit tests is to test the functionality of a class method or global function by testing the output of it, or catching errors. You expect a certain behaviour of the method/function depending on the value of the input parameters (or environmental states, like global variables, database content, or config settings). So basically you think of all different situations that can affect the behaviour of the method/function, define what kind of result this would give and write a test that sets up the situation and test (assert) the output of the function/method.
When writing unit tests, you should keep in mind that you are only testing the behaviour of that function/method. Any functions/methods used by a function/method should be tested seperately. By which I mean that you must assume when testing a function/method that the functions/methods that are used in that method, work correctly. To make things easier for you, you can define stubs/mocks [0] that replace the methods/functions used in a function/method you are testing. This way you don't have to set up a complete environment, but can concentrate on what the function/method does.
As an example
If you have a class that gets values from a database :
class DbValues { private $_values;
__construct() { $this->_values = array(); }
public function getValuesFromDb() { // functionality making a connection to a database, executing a query and setting the resulting values to $_values. }
public function getValues() { return $this->_values; }
public function count() { return count($this->getValues()); } }
And you want to test the behaviour of the count() method. The only way to populate the _values variable in this example would be by setting up a database with different sets of values, for each case you want to test and call the getValuesFromDb() method, OR, you can define a stub that replaces the getValues() method and let it return an array with the necessary amount of values (depending on what you want to test). This way you avoid having to set up a complicated testing environment, when testing a single class method. (Note : when testing the getValuesFromDb() method you will probably have to set up a database, but that's because that method is all about connecting to a database and getting data from it, but all other methods in this class can assume that the getValuesFromDb works, so there is no need to replicate the complicated test environment every time)
I suggest you read up a bit on testing class methods and the use of stubs/mocks. I hope my example didn't confuse you too much.
[0] http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs
Thank you very much for spending your time for clarify this with valuable and enough information. I completely agree with you, on writing unit tests independent/separate from another layer/function. Mock objects/stubs are helpful in that case.
At the moment there are around 25 private fields in PMA_DisplayResults class. What I am thinking of implement getter setter methods for all those and use getters and setters where needed. In that way I will be able to set those private fields even from the tests. What do you think on this ?
Regards ! -- ____________________________________
Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Phpmyadmin-devel mailing list Phpmyadmin-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
Hi Chanaka, When writing test cases we might have to test protected/private functions as well. The method used in PMA is by using php Refection class. They used setAccessible method to make them public for test class. There is a method in reflection class called getProperties which can used for access protected and private attributes. Refer this [1] for more details. But I am not sure is it a good approach when testing. [1] - http://php.net/manual/en/reflectionproperty.setaccessible.php Regards, -- Yasitha Pandithawatta Undergraduate Computer Science and Engineering Department University of Moratuwa Sri Lanka

Hi Dieter,
I almost reduce the use of super global variables inside functions of
PMA_DisplayResults class. Most of the fields are set while executing the getTable() function since they cannot set while executing the constructor.
Now I'm move into writing tests. I am facing to a problem with writing tests. How can I access or set the private variables, by a test ? The already existed tests also failing due to this change. Your suggestions will very helpful.
I didn't have a look at the current tests and at PMA_DisplayResults class, so I won't be able to go into specifics about your tests, but I will try to answer your questions, and point you in a direction.
Accessing or setting private variables in a class/method is not possible during a unit test. The idea of unit tests is to test the functionality of a class method or global function by testing the output of it, or catching errors. You expect a certain behaviour of the method/function depending on the value of the input parameters (or environmental states, like global variables, database content, or config settings). So basically you think of all different situations that can affect the behaviour of the method/function, define what kind of result this would give and write a test that sets up the situation and test (assert) the output of the function/method.
When writing unit tests, you should keep in mind that you are only testing the behaviour of that function/method. Any functions/methods used by a function/method should be tested seperately. By which I mean that you must assume when testing a function/method that the functions/methods that are used in that method, work correctly. To make things easier for you, you can define stubs/mocks [0] that replace the methods/functions used in a function/method you are testing. This way you don't have to set up a complete environment, but can concentrate on what the function/method does.
As an example
If you have a class that gets values from a database :
class DbValues { private $_values;
__construct() { $this->_values = array(); }
public function getValuesFromDb() { // functionality making a connection to a database, executing a query and setting the resulting values to $_values. }
public function getValues() { return $this->_values; }
public function count() { return count($this->getValues()); } }
And you want to test the behaviour of the count() method. The only way to populate the _values variable in this example would be by setting up a database with different sets of values, for each case you want to test and call the getValuesFromDb() method, OR, you can define a stub that replaces the getValues() method and let it return an array with the necessary amount of values (depending on what you want to test). This way you avoid having to set up a complicated testing environment, when testing a single class method. (Note : when testing the getValuesFromDb() method you will probably have to set up a database, but that's because that method is all about connecting to a database and getting data from it, but all other methods in this class can assume that the getValuesFromDb works, so there is no need to replicate the complicated test environment every time)
I suggest you read up a bit on testing class methods and the use of stubs/mocks. I hope my example didn't confuse you too much.
[0] http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.stubs
Thank you very much for spending your time for clarify this with valuable and enough information. I completely agree with you, on writing unit tests independent/separate from another layer/function. Mock objects/stubs are helpful in that case.
At the moment there are around 25 private fields in PMA_DisplayResults class. What I am thinking of implement getter setter methods for all those and use getters and setters where needed. In that way I will be able to set those private fields even from the tests. What do you think on this ?
Regards !
Hi Chanaka,
When writing test cases we might have to test protected/private functions as well. The method used in PMA is by using php Refection class. They used setAccessible method to make them public for test class. There is a method in reflection class called getProperties which can used for access protected and private attributes. Refer this [1] for more details. But I am not sure is it a good approach when testing.
[1] - http://php.net/manual/en/reflectionproperty.setaccessible.php
Hi Yasitha, Thanks for your information. I have already referred some tests done by you, accessing to private functions. I'll use the same way for testing private methods. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi, I introduced new function to initialize set of properties of PMA_DisplayResults class which are not set inside the constructor. That functions is appeared as processParams(). But I'm not sure its a good name for that method. Will a name like setProperties() or setAdditionalProperties() more suitable for this function ? Welcome to any suggestions. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

2012/7/10 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
Hi,
I introduced new function to initialize set of properties of PMA_DisplayResults class which are not set inside the constructor. That functions is appeared as processParams(). But I'm not sure its a good name for that method. Will a name like setProperties() or setAdditionalProperties() more suitable for this function ? Welcome to any suggestions.
Hi Chanaka, Assuming that you are talking about the properties that are not set with a constructor parameter (the properties should be defined in the constructor anyway, but not necessarely with a value supplied by a constructor parameter), I think setProperties() is the best choice. Would this method only set the properties that cannot be set with a constructor parameter, or just any property? Maybe you can consider calling it setProperty($name, $value). This enables you to set just any parameter. How are your properties defined? As single variables? Or as an array of properties? Kind regards, Dieter

Hi Dieter, Thanks for your suggestions.
I introduced new function to initialize set of properties of
PMA_DisplayResults class which are not set inside the constructor. That functions is appeared as processParams(). But I'm not sure its a good name for that method. Will a name like setProperties() or setAdditionalProperties() more suitable for this function ? Welcome to any suggestions.
Hi Chanaka,
Assuming that you are talking about the properties that are not set with a constructor parameter (the properties should be defined in the constructor anyway, but not necessarely with a value supplied by a constructor parameter), I think setProperties() is the best choice.
Yes, that's good.
Would this method only set the properties that cannot be set with a constructor parameter, or just any property?
This method only set the properties which cannot be set in constructor.
Maybe you can consider calling it setProperty($name, $value). This enables you to set just any parameter.
The class already have a method called __set($name, $value) to set any of the property in class. But since there are around 17 properties to initialized, I think better to use this setProperties() method.
How are your properties defined? As single variables? Or as an array of properties?
Sorry if I'm not calling to your question. (I'm not clear about what you try to ask.)
From the sql.php file I pass parameters to this function separately. ex - setProperties($property1, property2, etc.) Those properties are with different data types.
Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

2012/7/11 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com>:
Hi Dieter,
Thanks for your suggestions.
I introduced new function to initialize set of properties of PMA_DisplayResults class which are not set inside the constructor. That functions is appeared as processParams(). But I'm not sure its a good name for that method. Will a name like setProperties() or setAdditionalProperties() more suitable for this function ? Welcome to any suggestions.
Hi Chanaka,
Assuming that you are talking about the properties that are not set with a constructor parameter (the properties should be defined in the constructor anyway, but not necessarely with a value supplied by a constructor parameter), I think setProperties() is the best choice.
Yes, that's good.
Would this method only set the properties that cannot be set with a constructor parameter, or just any property?
This method only set the properties which cannot be set in constructor.
Maybe you can consider calling it setProperty($name, $value). This enables you to set just any parameter.
The class already have a method called __set($name, $value) to set any of the property in class. But since there are around 17 properties to initialized, I think better to use this setProperties() method.
How are your properties defined? As single variables? Or as an array of properties?
Sorry if I'm not calling to your question. (I'm not clear about what you try to ask.)
This is what I meant : Do you have a single array (or an container class) with properties, like : private $_properties = array(); or do you define all your properties seperately (ommiting the docblocks in this example) : private $_property1; private $_property2; private $_property3; ... private $_propertyN; Kind regards, Dieter

Thanks for your suggestions.
I introduced new function to initialize set of properties of PMA_DisplayResults class which are not set inside the constructor. That functions is appeared as processParams(). But I'm not sure its a good name for that method. Will a name like setProperties() or setAdditionalProperties() more suitable for this function ? Welcome to any suggestions.
Hi Chanaka,
Assuming that you are talking about the properties that are not set with a constructor parameter (the properties should be defined in the constructor anyway, but not necessarely with a value supplied by a constructor parameter), I think setProperties() is the best choice.
Yes, that's good.
Would this method only set the properties that cannot be set with a constructor parameter, or just any property?
This method only set the properties which cannot be set in constructor.
Maybe you can consider calling it setProperty($name, $value). This enables you to set just any parameter.
The class already have a method called __set($name, $value) to set any of the property in class. But since there are around 17 properties to initialized, I think better
to
use this setProperties() method.
How are your properties defined? As single variables? Or as an array of properties?
Sorry if I'm not calling to your question. (I'm not clear about what you try to ask.)
This is what I meant : Do you have a single array (or an container class) with properties, like :
private $_properties = array();
or do you define all your properties seperately (ommiting the docblocks in this example) :
private $_property1; private $_property2; private $_property3; ... private $_propertyN;
Hi Dieter, Now I got that. I have defined them separately as your second example. Regards ! -- ____________________________________ Chanaka Indrajith Bsc.Computer Engineering Undergraduate Faculty of Engineering University of Peradeniya Sri Lanka ____________________________________

Hi Michal, These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not. Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php Regards ! *Chanaka*

Hi Dne Thu, 12 Jul 2012 19:50:21 +0530 Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> napsal(a):
These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not.
First of all the tests should run standalone as well as part of testsuite. I see lot of tests fail in both modes, so maybe that's the reason why it fails for you?
Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php
Fix the tests and code to work together :-). -- Michal Čihař | http://cihar.com | http://phpmyadmin.cz

These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not.
First of all the tests should run standalone as well as part of testsuite. I see lot of tests fail in both modes, so maybe that's the reason why it fails for you?
Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php
Fix the tests and code to work together :-).
Okay I'll try again Michal

These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not.
First of all the tests should run standalone as well as part of testsuite. I see lot of tests fail in both modes, so maybe that's the reason why it fails for you?
Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php
Fix the tests and code to work together :-).
Okay I'll try again Michal
Hi Michal, I managed to run only needed tests by modifying phpunit.xml.dist file. And now Its no need to wait till all tests are running. The problem for the errors in PMA_DisplayResults_test.php tests is not properly set the properties of PMA_DisplayResults class. So that, I get following two types of errors : 1. Trying to get property of non-object - $fields_meta[0]->table 2. Invalid argument supplied for foreach() - foreach ($vertical_display[$operation] as $val) I try to set those parameters by calling setProperties() method. As I found, the conditions inside __set and __get method are not satisfying. That is, if (property_exists($this, $property)) But if I print the object at testing time, it shows me the properties are actually there itself. I am confusing about this. Do you have any idea or suggestion for this ? Regards ! *Chanaka*

On Fri, Jul 13, 2012 at 6:38 AM, Chanaka Dharmarathna < pe.chanaka.ck@gmail.com> wrote:
These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not.
First of all the tests should run standalone as well as part of testsuite. I see lot of tests fail in both modes, so maybe that's the reason why it fails for you?
Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php
Fix the tests and code to work together :-).
Okay I'll try again Michal
Hi Michal,
I managed to run only needed tests by modifying phpunit.xml.dist file. And now Its no need to wait till all tests are running.
The problem for the errors in PMA_DisplayResults_test.php tests is not properly set the properties of PMA_DisplayResults class. So that, I get following two types of errors : 1. Trying to get property of non-object - $fields_meta[0]->table 2. Invalid argument supplied for foreach() - foreach ($vertical_display[$operation] as $val)
I try to set those parameters by calling setProperties() method. As I found, the conditions inside __set and __get method are not satisfying.
That is, if (property_exists($this, $property))
But if I print the object at testing time, it shows me the properties are actually there itself. I am confusing about this. Do you have any idea or suggestion for this ?
Regards !
*Chanaka*
Hi Michal, I just found that, property_exists method cannot detect properties in magic method __get, from the manual [0]. I'll try with changing the method names. [0] : http://php.net/manual/en/function.property-exists.php Regards ! *Chanaka*

These days I'm having problems with improving the test cases. It's not a good idea to run all the tests after improve test for each function since it takes much time. As well I can't run tests individually without errors again and again. (File not found, undefined constant, undefined variable) I cannot find that my tests are correct or not.Chanaka
First of all the tests should run standalone as well as part of testsuite. I see lot of tests fail in both modes, so maybe that's the reason why it fails for you?
Please suggest me some way to get rid of this problem. Its very helpful if you can give one example for fixing a failing test in PMA_DisplayResults_test.php
Fix the tests and code to work together :-).
Okay I'll try again Michal
Hi Michal,
I managed to run only needed tests by modifying phpunit.xml.dist file. And now Its no need to wait till all tests are running.
The problem for the errors in PMA_DisplayResults_test.php tests is not properly set the properties of PMA_DisplayResults class. So that, I get following two types of errors : 1. Trying to get property of non-object - $fields_meta[0]->table 2. Invalid argument supplied for foreach() - foreach ($vertical_display[$operation] as $val)
I try to set those parameters by calling setProperties() method. As I found, the conditions inside __set and __get method are not satisfying.
That is, if (property_exists($this, $property))
But if I print the object at testing time, it shows me the properties are actually there itself. I am confusing about this. Do you have any idea or suggestion for this ?
Hi Michal,
I just found that, property_exists method cannot detect properties in magic method __get, from the manual [0]. I'll try with changing the method names.
Hi Michal, I try some modifications in those magic methods in order to fix those tests. I use an array to store the all properties instead of using separate set of properties. (I feel Dieter also try to say something like that in a previous mail) Now there is no doubt of using magic methods at any place. I need your suggestion before doing this change. Following snippet shows what I'm going to do. // initialize at the top so that any property should include here private $_properties_array = array('_db'=>null, '_table'=>null, .........); public function __set($property, $value) { if(array_key_exists($property, $this->_properties_array)) { // check array key is defined - this is same as check property exist $this->_properties_array[$property] = $value; } } public function __get($property) { if(array_key_exists($property, $this->_properties_array)) { return $this->_properties_array[$property]; } } Waiting for your suggestions. Regards ! *Chanaka*
participants (8)
-
Alex Marin
-
Chanaka Dharmarathna
-
Dieter Adriaenssens
-
Marc Delisle
-
Maria Medina
-
Michal Čihař
-
Rouslan Placella
-
yasitha pandithawatta