Skip to content
Snippets Groups Projects
Commit 942c54d4 authored by Alexander Hass's avatar Alexander Hass
Browse files

Status code 500 on HEAD/GET does not increase fail_count

parent b2cb5bac
No related branches found
No related tags found
No related merge requests found
......@@ -541,16 +541,21 @@ function _linkchecker_status_handling($link, $response) {
break;
case 405:
case 500:
// - 405: Special error handling if method is not allowed. Switch link
// checking to GET method and try again.
// - 500: Like WGET, try with GET on "500 Internal server error".
db_query("UPDATE {linkchecker_links} SET method = '%s' WHERE lid = %d", 'GET', $link->lid);
db_query("UPDATE {linkchecker_links} SET method = '%s', code = %d, error = '%s', fail_count = fail_count+1, last_checked = %d WHERE lid = %d", 'GET', $response->code, $response->error, time(), $link->lid);
watchdog('linkchecker', 'Method HEAD is not allowed for link %link. Method has been changed to GET.', array('%link' => $link->url), WATCHDOG_INFO, l(t('Broken links'), 'admin/reports/linkchecker'));
break;
if ($response->code == 405) {
watchdog('linkchecker', 'Method HEAD is not allowed for link %link. Method has been changed to GET.', array('%link' => $link->url), WATCHDOG_INFO, l(t('Broken links'), 'admin/reports/linkchecker'));
case 500:
// - 500: Like WGET, try with GET on "500 Internal server error".
// - If GET also fails with status code 500, than the link is broken.
if ($link->method == 'GET' && $response->code == 500) {
db_query("UPDATE {linkchecker_links} SET code = %d, error = '%s', fail_count = fail_count+1, last_checked = %d WHERE lid = %d", $response->code, $response->error, time(), $link->lid);
watchdog('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
}
elseif ($response->code == 500) {
else {
db_query("UPDATE {linkchecker_links} SET method = '%s', code = %d, error = '%s', fail_count = fail_count+1, last_checked = %d WHERE lid = %d", 'GET', $response->code, $response->error, time(), $link->lid);
watchdog('linkchecker', 'Internal server error for link %link. Method has been changed to GET.', array('%link' => $link->url), WATCHDOG_INFO, l(t('Broken links'), 'admin/reports/linkchecker'));
}
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment