Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

@@ 901-941 (lines=41) @@
898
 * @param int $line What line of $file the code which generated the error is on
899
 * @return void|array Returns an array with the file and line if $error_type is 'return'
900
 */
901
function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
902
{
903
	if (empty($log_message))
904
		$log_message = $error_message;
905
906
	foreach (debug_backtrace() as $step)
907
	{
908
		// Found it?
909
		if (strpos($step['function'], 'query') === false && !in_array(substr($step['function'], 0, 7), array('smf_db_', 'preg_re', 'db_erro', 'call_us')) && strpos($step['function'], '__') !== 0)
910
		{
911
			$log_message .= '<br>Function: ' . $step['function'];
912
			break;
913
		}
914
915
		if (isset($step['line']))
916
		{
917
			$file = $step['file'];
918
			$line = $step['line'];
919
		}
920
	}
921
922
	// A special case - we want the file and line numbers for debugging.
923
	if ($error_type == 'return')
924
		return array($file, $line);
925
926
	// Is always a critical error.
927
	if (function_exists('log_error'))
928
		log_error($log_message, 'critical', $file, $line);
929
930
	if (function_exists('fatal_error'))
931
	{
932
		fatal_error($error_message, $error_type);
933
934
		// Cannot continue...
935
		exit;
936
	}
937
	elseif ($error_type)
938
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
939
	else
940
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
941
}
942
943
/**
944
 * Escape the LIKE wildcards so that they match the character and not the wildcard.

Sources/Subs-Db-mysql.php 1 location

@@ 920-960 (lines=41) @@
917
 * @param int $line What line of $file the code which generated the error is on
918
 * @return void|array Returns an array with the file and line if $error_type is 'return'
919
 */
920
function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
921
{
922
	if (empty($log_message))
923
		$log_message = $error_message;
924
925
	foreach (debug_backtrace() as $step)
926
	{
927
		// Found it?
928
		if (strpos($step['function'], 'query') === false && !in_array(substr($step['function'], 0, 7), array('smf_db_', 'preg_re', 'db_erro', 'call_us')) && strpos($step['function'], '__') !== 0)
929
		{
930
			$log_message .= '<br>Function: ' . $step['function'];
931
			break;
932
		}
933
934
		if (isset($step['line']))
935
		{
936
			$file = $step['file'];
937
			$line = $step['line'];
938
		}
939
	}
940
941
	// A special case - we want the file and line numbers for debugging.
942
	if ($error_type == 'return')
943
		return array($file, $line);
944
945
	// Is always a critical error.
946
	if (function_exists('log_error'))
947
		log_error($log_message, 'critical', $file, $line);
948
949
	if (function_exists('fatal_error'))
950
	{
951
		fatal_error($error_message, false);
952
953
		// Cannot continue...
954
		exit;
955
	}
956
	elseif ($error_type)
957
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
958
	else
959
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
960
}
961
962
/**
963
 * Escape the LIKE wildcards so that they match the character and not the wildcard.