MyBB Community Forums

Full Version: Call to undefined function format_time_duration() and db_mysqli.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, in /log/apache2/error.log I have often this error:

Quote:[Sat Oct 11 16:55:12 2014] [error] [client 66.249.69.232] PHP Fatal error:  Call to undefined function format_time_duration() in /var/www/forum/inc/db_mysqli.php on line 229

Any idea on what could be the problem? or how to fix it? I'm on a VPS.

Thank you in advance
Do you have this line: https://github.com/mybb/mybb/blob/featur....php#L3658 in inc/functions.php?
Hi, in inc/functions.php I have that line:

/**
 * Format a decimal number in to microseconds, milliseconds, or seconds.
 *
 * @param int The time in microseconds
 * @return string The friendly time duration
 */
function format_time_duration($time)
{
	global $lang;

etc

/**
 * Prints a debug information page
 */
function debug_page()
{
	global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang, $cache;

	$totaltime = format_time_duration($maintimer->totaltime);
	$phptime = $maintimer->totaltime - $db->query_time;
	$query_time = $db->query_time;
	$globaltime = format_time_duration($globaltime);

	$percentphp = number_format((($phptime/$maintimer->totaltime)*100), 2);
	$percentsql = number_format((($query_time/$maintimer->totaltime)*100), 2);

	$phptime = format_time_duration($maintimer->totaltime - $db->query_time);
	$query_time = format_time_duration($db->query_time);

	$call_time = format_time_duration($cache->call_time);

etc

I installed MySql, can to be my wrong setting of MySql?
(2014-10-11, 06:32 PM)niere8 Wrote: [ -> ]I installed MySql, can to be my wrong setting of MySql?

Maybe. Make sure everything is configured properly.
Hi, here there is "hostname", this is about hostname of the VPS or other hostname?

$this->connections[] = "[".strtoupper($type)."] {$single_connection['username']}@{$single_connection['hostname']} (Connected in ".format_time_duration($time_spent).")";
Nodoby? Sad

In an announcement (only the last announcement) on Portal page I haven't hour, instead of (12-10-2014 14:34) I have only ()
bump, I'm also seeing this A LOT in my error logs. I'm running MySQLi 5.6.19

[Fri Jan 23 00:46:39.941069 2015] [:error] [pid 768] [client IP Address] FastCGI: server "/some/path" stderr: PHP Fatal error:  Call to undefined function format_time_duration() in /inc/db_mysqli.php on line 229

line 3658 is different in inc/functions.php as referenced above, I imagine since that was posted months ago.

I do have the bit posted by niere8 here around 3683:

/**
 * Format a decimal number in to microseconds, milliseconds, or seconds.
 *
 * @param int The time in microseconds
 * @return string The friendly time duration
 */
function format_time_duration($time)
{
	global $lang;

	if(!is_numeric($time))
	{
		return $lang->na;
	}

	if(round(1000000 * $time, 2) < 1000)
	{
		$time = number_format(round(1000000 * $time, 2))." μs";
	}
	elseif(round(1000000 * $time, 2) >= 1000 && round(1000000 * $time, 2) < 1000000)
	{
		$time = number_format(round((1000 * $time), 2))." ms";
	}
	else
	{
		$time = round($time, 3)." seconds";
	}

	return $time;
}
Could you try matching the error time/date to your access logs to try and see which page might be generating this? I'd guess the page for some reason doesn't have functions.php included...
(2015-01-23, 12:45 PM)Euan T Wrote: [ -> ]Could you try matching the error time/date to your access logs to try and see which page might be generating this? I'd guess the page for some reason doesn't have functions.php included...

yep, I'll look into that tonight.

I think there are some logs where it actually appended a referer URL.  let me check now...

edit to add:

[Fri Jan 23 21:35:23.728619 2015] [:error] [pid 24873] [client IP Address:52157] FastCGI: server "/some/path" stderr: PHP Fatal error:  Call to undefined function format_time_duration() in /inc/db_mysqli.php on line 229, referer: https://www.google.pl/

[Fri Jan 23 21:06:29.832996 2015] [:error] [pid 17415] [client IP Address:50308] FastCGI: server "/some/path" stderr: PHP Fatal error:  Call to undefined function format_time_duration() in /inc/db_mysqli.php on line 229, referer: https://www.google.co.uk/

[Fri Jan 23 18:59:07.086977 2015] [:error] [pid 27947] [client IP Address:49330] FastCGI: server "/some/path" stderr: PHP Fatal error:  Call to undefined function format_time_duration() in /inc/db_mysqli.php on line 229, referer: http://shavenook.com/thread-truefitt-hill-moonjava-best-badger
Unfortunately, referrer isn't of a lot of use as there's no way of knowing exactly which page was the cause of the issue (especially in the case of the two Google referrers).
Pages: 1 2