MyBB Community Forums
Fix PHP Notice in db_mysqli.php - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: MyBB 1.6 (https://community.mybb.com/forum-138.html)
+------ Forum: 1.6 Suggestions and Feedback (https://community.mybb.com/forum-7.html)
+------ Thread: Fix PHP Notice in db_mysqli.php (/thread-120337.html)



Fix PHP Notice in db_mysqli.php - Jan - 2012-06-12

Hi,

it would be nice, if you could fix the PHP Notice errors in db_mysqli.php. These are only very small changes. Maybe they can be included in the next bugfix version.

line 169:
if(!is_array($connections[$type]))
{
	break;
}
changed to
if(!isset($connections[$type]) || !is_array($connections[$type]))
{
	break;
}

line 198:
// Specified a custom port for this connection?
list($hostname, $port) = explode(":", $single_connection['hostname'], 2);
if($port)
{
	$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $port);
}
changed to
// Specified a custom port for this connection?
$host = explode(":", $single_connection['hostname'], 2);
if(isset($host[1]))
{
	$this->$link = @$connect_function($persist.$hostname, $single_connection['username'], $single_connection['password'], "", $host[1]);
}

This one will only be raised, if for any reason $mybb isn't defined. This will never happen in the productive system, but using the database object itself in a plugin or development process, this may happen.
line 324:
if($mybb->debug_mode)
{
	$this->explain_query($string, $query_time);
}
changed to
if(!empty($mybb) && $mybb->debug_mode)
{
	$this->explain_query($string, $query_time);
}



RE: Fix PHP Notice in db_mysqli.php - Nathan Malcolm - 2012-06-12

I'm pretty sure Rasmus Lerdorf fixed these. We'll be fixing a good deal of PHP notices in 1.6.9. Smile