Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

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

Sources/Subs-Db-mysql.php 1 location

@@ 866-906 (lines=41) @@
863
 * @param int $line What line of $file the code which generated the error is on
864
 * @return void|array Returns an array with the file and line if $error_type is 'return'
865
 */
866
function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
867
{
868
	if (empty($log_message))
869
		$log_message = $error_message;
870
871
	foreach (debug_backtrace() as $step)
872
	{
873
		// Found it?
874
		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)
875
		{
876
			$log_message .= '<br>Function: ' . $step['function'];
877
			break;
878
		}
879
880
		if (isset($step['line']))
881
		{
882
			$file = $step['file'];
883
			$line = $step['line'];
884
		}
885
	}
886
887
	// A special case - we want the file and line numbers for debugging.
888
	if ($error_type == 'return')
889
		return array($file, $line);
890
891
	// Is always a critical error.
892
	if (function_exists('log_error'))
893
		log_error($log_message, 'critical', $file, $line);
894
895
	if (function_exists('fatal_error'))
896
	{
897
		fatal_error($error_message, false);
898
899
		// Cannot continue...
900
		exit;
901
	}
902
	elseif ($error_type)
903
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
904
	else
905
		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
906
}
907
908
/**
909
 * Escape the LIKE wildcards so that they match the character and not the wildcard.