Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

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

Sources/Subs-Db-mysql.php 1 location

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