Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

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

Sources/Subs-Db-mysql.php 1 location

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