Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

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

Sources/Subs-Db-mysql.php 1 location

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