<div dir="ltr">On Thu, Apr 17, 2014 at 9:47 AM, Edward Cheng <span dir="ltr"><<a href="mailto:c4150221@gmail.com" target="_blank">c4150221@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I thought we have these code can avoid errors, in my new PR I improve it.<br>
<pre><br>
/**<br>
* Returns class instance.<br>
*<br>
* @param string $type the table type<br>
*<br>
* @return PMA_RecentFavoriteTable<br>
*/<br>
public static function getInstance($type)<br>
{<br>
if (is_null(self::$_instance)) {<br>
self::$_instance[$type] = new PMA_RecentFavoriteTable($type);<br>
} else {<br>
if (self::$_instance[$type]->table_type != $type) {<br>
self::$_instance[$type] = new PMA_RecentFavoriteTable($type);<br>
}<br>
}<br>
return self::$_instance[$type];<br>
}<br>
</pre><br>
Does my PR fix it?<br>
<br>
2014-04-17 0:02 GMT+08:00 Chanaka Dharmarathna <<a href="mailto:pe.chanaka.ck@gmail.com">pe.chanaka.ck@gmail.com</a>>:<br>
<div><div class="h5">> Hi,<br>
><br>
> It seems like, the latest PMA_RecentFavoriteTable is trying to behave as<br>
> singleton design pattern. Is that a requirement ? I mean is there any reason<br>
> for making it singleton ? By the way, there is good possibility to create<br>
> new instances again and again with current logic.<br>
><br>
> And the class has $table_type instance variable and more. Isn't it risky<br>
> behaviour to share a static instance throughout the web server, which has<br>
> instance variable which used in functions of that instance ?<br>
><br></div></div></blockquote><div><br></div><div>Hi Edward,<br><br></div><div>Your code does not avoid creating many instances. By the way, we better first clarify our self, the requirement. Any thoughts ?<br></div><div>
<br></div><div>Regards !<br></div></div>-- <br><div dir="ltr"><font size="4">Chanaka Dharmarathna<br></font><div><a href="http://chanakaindrajith.blogspot.com/" target="_blank"><font color="#999999"><b>http://chanakaindrajith.blogspot.com/</b></font></a></div>
</div>
</div></div>