Code Duplication    Length = 41-41 lines in 2 locations

Sources/Subs-Db-postgresql.php 1 location

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

Sources/Subs-Db-mysql.php 1 location

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