Skip to content

Commit c9d4998

Browse files
authored
Merge pull request #8998 from live627/log
[2.1] Ignore errors when attempting to log errors
2 parents c759013 + 7c299ba commit c9d4998

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Sources/Errors.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,18 @@ function log_error($error_message, $error_type = 'general', $file = null, $line
135135
$query = $smcFunc['db_query']('', '
136136
SELECT COUNT(*)
137137
FROM {db_prefix}log_errors',
138-
array()
138+
array(
139+
'db_error_skip' => true,
140+
)
139141
);
140142

141-
list($context['num_errors']) = $smcFunc['db_fetch_row']($query);
142-
$smcFunc['db_free_result']($query);
143+
if ($query)
144+
{
145+
list($context['num_errors']) = $smcFunc['db_fetch_row']($query);
146+
$smcFunc['db_free_result']($query);
147+
}
148+
else
149+
$context['num_errors'] = 0;
143150
}
144151
else
145152
$context['num_errors']++;
@@ -582,8 +589,13 @@ function log_error_online($error, $sprintf = array())
582589
WHERE session = {string:session}',
583590
array(
584591
'session' => $session_id,
592+
'db_error_skip' => true,
585593
)
586594
);
595+
596+
if (!$request)
597+
return;
598+
587599
if ($smcFunc['db_num_rows']($request) != 0)
588600
{
589601
// If this happened very early on in SMF startup, $smcFunc may not fully be defined.

Sources/Subs-Db-mysql.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ function smf_db_insert($method, $table, $columns, $data, $keys, $returnmode = 0,
787787
', $insertRows),
788788
array(
789789
'security_override' => true,
790-
'db_error_skip' => $table === $db_prefix . 'log_errors',
790+
'db_error_skip' => preg_match('/log_errors|sessions/', $table),
791791
),
792792
$connection
793793
);
@@ -1003,6 +1003,9 @@ function smf_db_error_insert($error_array)
10031003
VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?, ?)'
10041004
);
10051005

1006+
if (empty($mysql_error_data_prep))
1007+
return;
1008+
10061009
if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false)
10071010
$error_array[2] = bin2hex(inet_pton($error_array[2]));
10081011
else

0 commit comments

Comments
 (0)