diff --git a/linkchecker.module b/linkchecker.module
index fdc7d23..79fa55a 100644
--- a/linkchecker.module
+++ b/linkchecker.module
@@ -11,9 +11,18 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Session\UserSession;
 use Drupal\node\NodeTypeInterface;
-use GuzzleHttp\Exception\RequestException;
-
-
+use Drupal\field\FieldConfigInterface;
+use Drupal\filter\Entity\FilterFormat;
+use Drupal\Component\Utility\Html;
+use Drupal\node\Entity\Node;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\filter\Entity;
+use Drupal\Component\Utility\UrlHelper;
+use Drupal\Core\Logger\RfcLogLevel;
+use Drupal\Component\Utility\Unicode;
+use Drupal\Component\Utility\Timer;
+use Drupal\Core\Database\Database;
+use Drupal\Core\Url;
 /**
  * Defines the maximum limit of links collected in one chunk if content is
  * scanned for links. A value that is too high may overload the database server.
@@ -96,11 +105,11 @@ function linkchecker_help($route_name, RouteMatchInterface $route_match) {
  *   The severity of the message; one of the following values as defined in
  *   @link http://www.faqs.org/rfcs/rfc3164.html RFC 3164: @endlink
  *   - WATCHDOG_EMERGENCY: Emergency, system is unusable.
- *   - WATCHDOG_ALERT: Alert, action must be taken immediately.
- *   - WATCHDOG_CRITICAL: Critical conditions.
+ *   - RfcLogLevel::ALERT: Alert, action must be taken immediately.
+ *   - RfcLogLevel::CRITICAL: Critical conditions.
  *   - WATCHDOG_ERROR: Error conditions.
  *   - WATCHDOG_WARNING: Warning conditions.
- *   - WATCHDOG_NOTICE: (default) Normal but significant conditions.
+ *   - RfcLogLevel::NOTICE: (default) Normal but significant conditions.
  *   - WATCHDOG_INFO: Informational messages.
  *   - WATCHDOG_DEBUG: Debug-level messages.
  * @param $link
@@ -109,9 +118,11 @@ function linkchecker_help($route_name, RouteMatchInterface $route_match) {
  * @see watchdog_severity_levels()
  * @see watchdog()
  */
-function linkchecker_watchdog_log($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
-  if ($severity <= variable_get('linkchecker_log_level', WATCHDOG_INFO)) {
-    watchdog($type, $message, $variables, $severity, $link);
+function linkchecker_watchdog_log($type, $message, $variables = array(), $severity =  RfcLogLevel::NOTICE, $link = NULL) {
+  if ($severity <= \Drupal::config('linkchecker.settings')->get('logging.level', RfcLogLevel::INFO)) {
+    $logger = \Drupal::logger($type);
+    $logger->log($severity, $message, $variables);
+
   }
 }
 
@@ -124,12 +135,11 @@ function linkchecker_watchdog_log($type, $message, $variables = array(), $severi
  * @return int|bool
  */
 function _linkchecker_user_access_account_broken_links_report($account) {
-  global $user;
-
+  $user = \Drupal::currentUser();
   // Users with 'access own broken links report' permission can only view their
   // own report. Users with the 'access broken links report' permission can
   // view the report for any authenticated user.
-  return $account->uid && (($user->uid == $account->uid && user_access('access own broken links report')) || user_access('access broken links report'));
+  return $account->uid && (($user->uid == $account->uid && \Drupal::currentUser()->hasPermission('access own broken links report')) || \Drupal::currentUser()->hasPermission('access broken links report'));
 }
 
 /**
@@ -142,7 +152,9 @@ function _linkchecker_user_access_account_broken_links_report($account) {
  *   TRUE if the current user has the requested permission.
  */
 function _linkchecker_user_access_edit_link_settings($link) {
-  return user_access('edit link settings') && _linkchecker_link_access($link);
+
+  return \Drupal::currentUser()->hasPermission('edit link settings') && _linkchecker_link_access($link);
+
 }
 
 /**
@@ -192,28 +204,32 @@ function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
 
   // Exit if all node types are disabled or if the user cannot access content,
   // there is no need to check further.
-  $linkchecker_scan_nodetypes = linkchecker_scan_node_types();
-  if (empty($linkchecker_scan_nodetypes) || !user_access('access content')) {
-    return array();
-  }
+ // $linkchecker_scan_nodetypes = linkchecker_scan_node_types();
+ // if (empty($linkchecker_scan_nodetypes) || !\Drupal::currentUser()->hasPermission('access content')) {
+  //  return array();
+  //}
 
   // Get a list of nodes containing the link, using addTag('node_access') to
   // allow node access modules to exclude nodes that the current user does not
   // have access to view.
   if (!empty($node_author_account)) {
-    $query = db_select('node', 'n');
+
+    //$query = db_select('node', 'n');
+    $query = \Drupal::database()->select('node', 'n');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_node', 'ln', 'ln.nid = n.nid');
     $query->innerJoin('node_revision', 'r', 'r.vid = n.vid');
     $query->condition('ln.lid', $link->lid);
-    $query->condition(db_or()
-      ->condition('n.uid', $node_author_account->uid)
-      ->condition('r.uid', $node_author_account->uid)
-    );
+    $or_condition_group =  $query->orConditionGroup()
+        ->condition('n.uid', $node_author_account->uid)
+        ->condition('r.uid', $node_author_account->uid);
+    $query->condition($or_condition_group);
+
     $query->fields('n', array('nid'));
   }
   else {
-    $query = db_select('node', 'n');
+    //$query = db_select('node', 'n');
+    $query = \Drupal::database()->select('node', 'n');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_node', 'ln', 'ln.nid = n.nid');
     $query->condition('ln.lid', $link->lid);
@@ -228,29 +244,29 @@ function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
   $access_allowed = FALSE;
   foreach ($nodes as $node) {
     if ($access_allowed) {
-      $nids[] = $node->nid;
+      $nids[] = $node->id();
       continue;
     }
-    $node = node_load($node->nid);
+    $node = Node::load($node->id());
 
     // We must check whether the link is currently part of the node; if not, we
     // do not want to return it (and it is not safe to, since we cannot know if
     // it contained access restrictions for the current user at the point which
     // it was originally extracted by the Link checker module).
-    if (!isset($fields_with_node_links[$node->nid])) {
-      $fields_with_node_links[$node->nid] = _linkchecker_extract_node_links($node, TRUE);
+    if (!isset($fields_with_node_links[$node->id()])) {
+      $fields_with_node_links[$node->id()] = _linkchecker_extract_node_links($node, TRUE);
     }
-    if (empty($fields_with_node_links[$node->nid][$link->url])) {
+    if (empty($fields_with_node_links[$node->id()][$link->url])) {
       continue;
     }
     // If the link appears in fields and a field access module is being used,
     // we must check that the current user has access to view at least one field
     // that contains the link; if they don't, we should not return the node.
-    $fields = $fields_with_node_links[$node->nid][$link->url];
-    if (module_implements('field_access')) {
+    $fields = $fields_with_node_links[$node->id()][$link->url];
+    if (\Drupal::moduleHandler()->getImplementations('field_access')) {
       $fields_with_access = array();
 
-      $bundle_instances = field_info_instances('node', $node->type);
+      $bundle_instances = field_info_instances('node', $node->bundle());
       foreach ($bundle_instances as $field_name => $field_instance) {
         $field = field_info_field($field_name);
 
@@ -272,7 +288,7 @@ function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
         continue;
       }
     }
-    $nids[] = $node->nid;
+    $nids[] = $node->id();
     $access_allowed = TRUE;
   }
 
@@ -297,7 +313,7 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
   // Exit if comments are disabled or if the user cannot access comments, there
   // is no need to check further.
   $comment_types = linkchecker_scan_comment_types();
-  if (empty($comment_types) || !user_access('access comments')) {
+  if (empty($comment_types) || !\Drupal::currentUser()->hasPermission('access comments')) {
     return array();
   }
 
@@ -305,7 +321,8 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
   // allow comment access modules to exclude comments that the current user
   // does not have access to view.
   if (!empty($comment_author_account)) {
-    $query = db_select('comment', 'c');
+    //$query = db_select('comment', 'c');
+    $query = \Drupal::database()->select('comment', 'c');
     $query->addMetaData('base_table', 'comment');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_comment', 'lc', 'lc.cid = c.cid');
@@ -314,7 +331,8 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
     $query->fields('c', array('cid'));
   }
   else {
-    $query = db_select('comment', 'c');
+    //$query = db_select('comment', 'c');
+    $query = \Drupal::database()->select('comment', 'c');
     $query->addMetaData('base_table', 'comment');
     $query->addTag('node_access');
     $query->innerJoin('linkchecker_comment', 'lc', 'lc.cid = c.cid');
@@ -338,32 +356,38 @@ function _linkchecker_link_comment_ids($link, $comment_author_account = NULL) {
  *   current user is allowed to view.
  */
 function _linkchecker_link_block_ids($link) {
+  $user = Drupal::currentUser();
   // Exit if blocks are disabled.
-  if (!variable_get('linkchecker_scan_blocks', 0)) {
+  if (!\Drupal::config('linkchecker.settings')->get('scan_blocks', 0)) {
     return array();
   }
 
   // Get the initial list of block IDs.
-  $bids = db_query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid))->fetchCol();
+  //$bids = db_query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid))->fetchCol();
+
+  $connection = \Drupal::database();
+  $query = $connection->query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid));
+  $bids = $query->fetchCol();
+
 
   // If the user can administer blocks, they're able to see all block content.
-  if (user_access('administer blocks')) {
+  if ($user->hasPermission('administer blocks')) {
     return $bids;
   }
 
   // Otherwise, only return blocks that this user (or anonymous users) have
   // access to.
-  global $user;
-  $rids = array_keys($user->roles);
-  $rids[] = DRUPAL_ANONYMOUS_RID;
+ // global $user;
+  $rids = array_keys($user->getRoles());
+  $rids[] = AccountInterface::ANONYMOUS_ROLE;
 
-  $query = db_select('block', 'b');
+  $query = \Drupal::database()->select('block', 'b');
   $query->leftJoin('block_role', 'r', 'b.module = r.module AND b.delta = r.delta');
   $query->condition('b.module', 'block');
-  $query->condition(db_or()
-    ->condition('r.rid', $rids, 'IN')
-    ->isNull('r.rid')
-  );
+  $or_condition_group =  $query->orConditionGroup()
+               ->condition('r.rid', $rids, 'IN')
+               ->isNull('r.rid');
+  $query->condition($or_condition_group);
   $query->fields('b', array('delta'));
   $query->distinct();
   $allowed_bids = $query->execute()->fetchCol();
@@ -412,119 +436,128 @@ function _linkchecker_check_links() {
   // Make sure this is the only process trying to run this function.
   $lock = \Drupal::lock();
   if ($lock->acquire(__FUNCTION__, $max_execution_time)) {
-    linkchecker_watchdog_log('linkchecker', 'Attempted to re-run link checks while they are already running.', array(), WATCHDOG_WARNING);
-    return FALSE;
-  }
 
-  $has_httprl = (\Drupal::moduleHandler()->moduleExists('httprl') && $config->get('check.library') == 'httprl');
+    $has_httprl = (\Drupal::moduleHandler()->moduleExists('httprl') && $config->get('check.library') == 'httprl');
 
-  // Do not confuse admins with a setting of maximum checkable links per cron
-  // run and guess that 2 links can be checked per second with 1 thread, what is
-  // nevertheless uncommon. The max_execution_time can be used to calculate
-  // a useful value that is higher, but not totally out of scope and limits the
-  // query result set to a reasonable size.
-  $linkchecker_check_connections_max = $config->get('check.connections_max');
-  $check_links_max_per_cron_run = ($has_httprl) ? ($linkchecker_check_connections_max * $max_execution_time) : $max_execution_time;
+    // Do not confuse admins with a setting of maximum checkable links per cron
+    // run and guess that 2 links can be checked per second with 1 thread, what is
+    // nevertheless uncommon. The max_execution_time can be used to calculate
+    // a useful value that is higher, but not totally out of scope and limits the
+    // query result set to a reasonable size.
+    $linkchecker_check_connections_max = $config->get('check.connections_max');
+    $check_links_max_per_cron_run = ($has_httprl) ? ($linkchecker_check_connections_max * $max_execution_time) : $max_execution_time;
 
-  $linkchecker_check_links_interval = $config->get('check.interval');
-  $linkchecker_check_useragent = $config->get('check.useragent');
+    $linkchecker_check_links_interval = $config->get('check.interval');
+    $linkchecker_check_useragent = $config->get('check.useragent');
 
-  // Connection limit can be overridden via settings.php. Two connections is the
-  // limit defined in RFC http://www.ietf.org/rfc/rfc2616.txt. Modern browsers
-  // are typically using 6-8 connections and no more. Never use more and keep
-  // in mind that you can overload other people servers.
-  $linkchecker_check_domain_connections = $config->get('check.connections_max_per_domain');
+    // Connection limit can be overridden via settings.php. Two connections is the
+    // limit defined in RFC http://www.ietf.org/rfc/rfc2616.txt. Modern browsers
+    // are typically using 6-8 connections and no more. Never use more and keep
+    // in mind that you can overload other people servers.
+    $linkchecker_check_domain_connections = $config->get('check.connections_max_per_domain');
 
-  // Get URLs for checking.
-  $links = db_query_range('SELECT * FROM {linkchecker_link} WHERE last_checked < :last_checked AND status = :status ORDER BY last_checked, lid ASC', 0, $check_links_max_per_cron_run, [':last_checked' => REQUEST_TIME - $linkchecker_check_links_interval, ':status' => 1]);
-  $links_remaining = $links->rowCount();
+    // Get URLs for checking.
+    $connection = \Drupal::database();
+    $links = $connection->queryRange('SELECT * FROM {linkchecker_link} WHERE last_checked < :last_checked AND status = :status ORDER BY last_checked, lid ASC', 0, $check_links_max_per_cron_run, [':last_checked' => REQUEST_TIME - $linkchecker_check_links_interval, ':status' => 1]);
+    $links_remaining = Database::RETURN_AFFECTED;
 
-  foreach ($links as $link) {
-    $headers = [];
-    $headers['User-Agent'] = $linkchecker_check_useragent;
+    foreach ($links as $link) {
+      $headers = [];
+      $headers['User-Agent'] = $linkchecker_check_useragent;
+
+      $uri = @parse_url($link->url);
+
+      // URL contains a fragment.
+      if (in_array($link->method, ['HEAD', 'GET']) && !empty($uri['fragment'])) {
+        // We need the full content and not only the HEAD.
+        $link->method = 'GET';
+        // Request text content only (like Firefox/Chrome).
+        $headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
+      } elseif ($link->method == 'GET') {
+        // Range: Only request the first 1024 bytes from remote server. This is
+        // required to prevent timeouts on URLs that are large downloads.
+        $headers['Range'] = 'bytes=0-1024';
+      }
 
-    $uri = @parse_url($link->url);
+      // Add in the headers.
+      $options = [
+          'headers' => $headers,
+          'method' => $link->method,
+          'max_redirects' => 0,
+      ];
 
-    // URL contains a fragment.
-    if (in_array($link->method, ['HEAD', 'GET']) && !empty($uri['fragment'])) {
-      // We need the full content and not only the HEAD.
-      $link->method = 'GET';
-      // Request text content only (like Firefox/Chrome).
-      $headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
-    }
-    elseif ($link->method == 'GET') {
-      // Range: Only request the first 1024 bytes from remote server. This is
-      // required to prevent timeouts on URLs that are large downloads.
-      $headers['Range'] = 'bytes=0-1024';
-    }
+      if ($has_httprl) {
+        // Define the callback and add the $link object to it.
+        // Notes:
+        // - 'global_timeout' does not require a timer_read('page'), as this job
+        //   runs in a new process, independent of cron.
+        $options += [
+            'global_connections' => $linkchecker_check_connections_max,
+            'global_timeout' => $max_execution_time - 30,
+            'domain_connections' => $linkchecker_check_domain_connections,
+            'callback' => [
+                [
+                    'function' => '_linkchecker_status_handling',
+                ],
+                $link, // This need to be passed or it's not send back to _linkchecker_status_handling()
+            ],
+        ];
+        // Queue up the requests.
+        httprl_request($link->url, $options);
+        $links_remaining--;
+
+        // After all links are queued, run the url checks.
+        if ($links_remaining == 0) {
+          httprl_send_request();
+        }
+      } else {
+        // Drupal core.
+        try {
+          // @fixme: Object is totally different in D8.
 
-    // Add in the headers.
-    $options = [
-      'headers' => $headers,
-      'method' => $link->method,
-      'max_redirects' => 0,
-    ];
+          $response = \Drupal::httpClient()->request($link->method, $link->url, $options);
 
-    if ($has_httprl) {
-      // Define the callback and add the $link object to it.
-      // Notes:
-      // - 'global_timeout' does not require a timer_read('page'), as this job
-      //   runs in a new process, independent of cron.
-      $options += [
-        'global_connections' => $linkchecker_check_connections_max,
-        'global_timeout' => $max_execution_time - 30,
-        'domain_connections' => $linkchecker_check_domain_connections,
-        'callback' => [
-          [
-            'function' => '_linkchecker_status_handling',
-          ],
-          $link, // This need to be passed or it's not send back to _linkchecker_status_handling()
-        ],
-      ];
-      // Queue up the requests.
-      httprl_request($link->url, $options);
-      $links_remaining--;
 
-      // After all links are queued, run the url checks.
-      if ($links_remaining == 0) {
-        httprl_send_request();
-      }
-    }
-    else {
-      // Drupal core.
-      try {
-        // @fixme: Object is totally different in D8.
-        $response = \Drupal::httpClient()->request($link->method, $link->url, $options);
-        //$response = drupal_http_request($link->url, $options);
-
-        // @fixme
-        // Add 'redirect_code' property to core response object for consistency
-        // with HTTPRL object.
-        //if ($response->code == 301 && !isset($response->redirect_code)) {
-        //  $response->redirect_code = $response->code;
-        //}
-        // Add 'uri' property to core response object for 'fragment' check and
-        // consistency with HTTPRL object.
-        //$response->uri = $uri;
-
-        _linkchecker_status_handling($response, $link);
-
-        if ((timer_read('page') / 1000) > ($max_execution_time / 2)) {
-          // Stop once we have used over half of the maximum execution time.
-          break;
+          // @fixme
+          // Add 'redirect_code' property to core response object for consistency
+          // with HTTPRL object.
+          //if ($response->code == 301 && !isset($response->redirect_code)) {
+          //  $response->redirect_code = $response->code;
+          //}
+          // Add 'uri' property to core response object for 'fragment' check and
+          // consistency with HTTPRL object.
+          //$response->uri = $uri;
+
+
+          _linkchecker_status_handling($response, $link);
+
+          if ((Timer::read('page') / 1000) > ($max_execution_time / 2)) {
+              // Stop once we have used over half of the maximum execution time.
+              break;
+          }
+        } catch (\GuzzleHttp\Exception\ClientException $e) {
+          $response = $e->getResponse();
+          _linkchecker_status_handling($response, $link);
+          if ((Timer::read('page') / 1000) > ($max_execution_time / 2)) {
+            // Stop for loop.
+            break;
+          }
+
         }
       }
-      catch (RequestException $exception) {
-        watchdog_exception('linkchecker', $exception);
-      }
     }
-  }
 
-  // Release the lock.
-  $lock->release(__FUNCTION__);
-  linkchecker_watchdog_log('linkchecker', 'Link checks completed.', array(), WATCHDOG_INFO);
-  linkchecker_watchdog_log('linkchecker', 'Memory usage: @memory_get_usage, Peak memory usage: @memory_get_peak_usage.', array('@memory_get_peak_usage' => format_size(memory_get_peak_usage()), '@memory_get_usage' => format_size(memory_get_usage())), WATCHDOG_DEBUG);
-  return TRUE;
+    // Release the lock.
+    $lock->release(__FUNCTION__);
+
+    linkchecker_watchdog_log('linkchecker', 'Memory usage: @memory_get_usage, Peak memory usage: @memory_get_peak_usage.', array('@memory_get_peak_usage' => format_size(memory_get_peak_usage()), '@memory_get_usage' => format_size(memory_get_usage())), RfcLogLevel::DEBUG);
+    return TRUE;
+
+  }
+  else {
+    linkchecker_watchdog_log('linkchecker', 'Attempted to re-run link checks while they are already running.', array(), RfcLogLevel::WARNING);
+    return FALSE;
+  }
 }
 
 /**
@@ -538,7 +571,7 @@ function _linkchecker_check_links() {
  */
 function _linkchecker_status_handling(&$response, $link) {
   $config = \Drupal::config('linkchecker.settings');
-  $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+  $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes', "200\n206\n302\n304\n401\n403"));
 
   // - Prevent E_ALL warnings in DB updates for non-existing $response->error.
   // - @todo drupal_http_request() may not provide an UTF8 encoded error message
@@ -551,8 +584,8 @@ function _linkchecker_status_handling(&$response, $link) {
   if (!isset($response->status_message)) {
     $response->status_message = '';
   }
-  $response->error = trim(drupal_convert_to_utf8($response->error, 'ISO-8859-1'));
-  $response->status_message = trim(drupal_convert_to_utf8($response->status_message, 'ISO-8859-1'));
+  $response->error = trim(Unicode::convertToUtf8($response->error, 'ISO-8859-1'));
+  $response->status_message = trim(Unicode::convertToUtf8($response->status_message, 'ISO-8859-1'));
 
   // Destination anchors in HTML documents may be specified either by:
   // - the A element (naming it with the name attribute)
@@ -563,14 +596,16 @@ function _linkchecker_status_handling(&$response, $link) {
   // - and must not contain '/' or ',' as this are not normal anchors.
   // - and '#top' is a reserved fragment that must not exist in a page.
   // See http://www.w3.org/TR/html401/struct/links.html
+
+  $response->code = $response->getStatusCode();
   if ($response->code == 200
-    && !empty($response->data)
-    && !empty($response->headers['content-type'])
-    && !empty($response->uri['fragment'])
-    && preg_match('/=|\/|,/', $response->uri['fragment']) == FALSE
-    && !in_array($response->uri['fragment'], array('#top'))
-    && in_array($response->headers['content-type'], array('text/html', 'application/xhtml+xml', 'application/xml'))
-    && !preg_match('/(\s[^>]*(name|id)(\s+)?=(\s+)?["\'])(' . preg_quote($response->uri['fragment'], '/') . ')(["\'][^>]*>)/i', $response->data)
+    && !empty($response->getBody())
+    && !empty($response->getHeader('Content-Type'))
+    && !empty($response->getHeader('Link'))
+    && preg_match('/=|\/|,/', $response->getHeader('Link')[1]) == FALSE
+    && !in_array($response->getHeader('Link')[1], array('#top'))
+    && in_array($response->getHeader('Content-Type'), array('text/html', 'application/xhtml+xml', 'application/xml'))
+    && !preg_match('/(\s[^>]*(name|id)(\s+)?=(\s+)?["\'])(' . preg_quote($response->getHeader('Link')[1], '/') . ')(["\'][^>]*>)/i', $response->getBody())
     ) {
     // Override status code 200 with status code 404 so it can be handled with
     // default status code 404 logic and custom error text.
@@ -586,57 +621,60 @@ function _linkchecker_status_handling(&$response, $link) {
     case -2: // HTTPRL: maximum allowed redirects exhausted.
     case 301:
       // Remote site send status code 301 and link needs an update.
-      db_update('linkchecker_link')
+     \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'code' => $response->redirect_code,
           'error' => $response->status_message,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
+
       // A HTTP status code of 301 tells us an existing link have changed to
       // a new link. The remote site owner was so kind to provide us the new
       // link and if we trust this change we are able to replace the old link
       // with the new one without any hand work.
-      $auto_repair_301 = variable_get('linkchecker_action_status_code_301', 0);
-      if ($auto_repair_301 && $auto_repair_301 <= ($link->fail_count + 1) && valid_url($response->redirect_url, TRUE)) {
+      $auto_repair_301 = \Drupal::config('linkchecker.settings')->get('error.action_status_code_301', 0);
+      if ($auto_repair_301 && $auto_repair_301 <= ($link->fail_count + 1) && UrlHelper::isValid($response->redirect_url, TRUE)) {
         // Switch anonymous user to an admin.
         $accountSwitcher = Drupal::service('account_switcher');
         $accountSwitcher->switchTo(new UserSession(array('uid' => user_load_by_name($config->get('error.impersonate_account')))));
 
         // NODES: Autorepair all nodes having this outdated link.
-        $result = db_query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $link->lid));
+        $connection = \Drupal::database();
+        $result = $connection->query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $link->lid));
+
         foreach ($result as $row) {
-          // Explicitly don't use node_load_multiple() or the module may run
+          // Explicitly don't use Node::load_multiple() or the module may run
           // into issues like http://drupal.org/node/1210606. With this logic
           // nodes can be updated until an out of memory occurs and further
           // updates will be made on the remaining nodes only.
-          $node = node_load($row->nid);
-
+          $node = Node::load($row->nid);
           // Has the node object loaded successfully?
           if (is_object($node)) {
             $node_original = clone $node;
-            $node = _linkchecker_replace_fields('node', $node->type, $node, $link->url, $response->redirect_url);
+            $node = _linkchecker_replace_fields('node', $node->bundle(), $node, $link->url, $response->redirect_url);
 
             if ($node_original != $node) {
               // Always use the default revision setting. For more information,
               // see node_object_prepare().
-              $node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
+              $node_options = \Drupal::config('linkchecker.settings')->get('node_options_' . $node->bundle(), array('status', 'promote'));
               $node->revision = in_array('revision', $node_options);
 
               // Generate a log message for the node_revisions table, visible on
               // the node's revisions tab.
-              $node->log = t('Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->nid), '%src' => $link->url, '%dst' => $response->redirect_url));
+              $node->log = t('Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->id()), '%src' => $link->url, '%dst' => $response->redirect_url));
 
               // Save changed node and update the node link list.
-              node_save($node);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->nid), '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              //Node::create($node);
+              $node->save();
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in %node from %src to %dst.', array('%node' => url('node/' . $node->id()), '%src' => $link->url, '%dst' => $response->redirect_url), RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in node failed. Permanently moved link %src not found in node %node. Manual fix required.', array('%node' => url('node/' . $row->nid), '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in node failed. Permanently moved link %src not found in node %node. Manual fix required.', array('%node' => url('node/' . $row->nid), '%src' => $link->url), RfcLogLevel::WARNING);
             }
           }
           else {
@@ -645,7 +683,9 @@ function _linkchecker_status_handling(&$response, $link) {
         }
 
         // COMMENTS: Autorepair all comments having this outdated link.
-        $result = db_query('SELECT cid FROM {linkchecker_comment} WHERE lid = :lid', array(':lid' => $link->lid));
+        $connection = \Drupal::database();
+        $result = $connection->query('SELECT cid FROM {linkchecker_comment} WHERE lid = :lid', array(':lid' => $link->lid));
+
         foreach ($result as $row) {
           // Explicitly don't use comment_load_multiple() or the module may run
           // into issues like http://drupal.org/node/1210606. With this logic
@@ -666,10 +706,10 @@ function _linkchecker_status_handling(&$response, $link) {
             // Save changed comment and update the comment link list.
             if ($comment_original != $comment) {
               comment_save($comment);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in comment %comment from %src to %dst.', array('%comment' => $comment->cid, '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in comment %comment from %src to %dst.', array('%comment' => $comment->cid, '%src' => $link->url, '%dst' => $response->redirect_url), RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in comment failed. Permanently moved link %src not found in comment %comment. Manual fix required.', array('%comment' => $comment->cid, '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in comment failed. Permanently moved link %src not found in comment %comment. Manual fix required.', array('%comment' => $comment->cid, '%src' => $link->url), RfcLogLevel::WARNING);
             }
           }
           else {
@@ -679,7 +719,9 @@ function _linkchecker_status_handling(&$response, $link) {
 
         // CUSTOM BLOCKS: Autorepair all custom blocks having this outdated
         // link.
-        $result = db_query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid));
+       $connection = \Drupal::database();
+        $result = $connection->query('SELECT bid FROM {linkchecker_block_custom} WHERE lid = :lid', array(':lid' => $link->lid));
+
         foreach ($result as $row) {
           $block_custom = linkchecker_block_custom_block_get($row->bid);
 
@@ -698,14 +740,14 @@ function _linkchecker_status_handling(&$response, $link) {
               // There is no hook that fires on block_custom_block_save(),
               // therefore do link extraction programmatically.
               _linkchecker_add_block_custom_links($block_custom, $block_custom->delta);
-              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in custom block %bid from %src to %dst.', array('%bid' => $block_custom->delta, '%src' => $link->url, '%dst' => $response->redirect_url), WATCHDOG_INFO);
+              linkchecker_watchdog_log('linkchecker', 'Changed permanently moved link in custom block %bid from %src to %dst.', array('%bid' => $block_custom->delta, '%src' => $link->url, '%dst' => $response->redirect_url), RfcLogLevel::INFO);
             }
             else {
-              linkchecker_watchdog_log('linkchecker', 'Link update in block failed. Permanently moved link %src not found in block %bid. Manual fix required.', array('%bid' => $block_custom->delta, '%src' => $link->url), WATCHDOG_WARNING);
+              linkchecker_watchdog_log('linkchecker', 'Link update in block failed. Permanently moved link %src not found in block %bid. Manual fix required.', array('%bid' => $block_custom->delta, '%src' => $link->url), RfcLogLevel::WARNING);
             }
           }
           else {
-            linkchecker_watchdog_log('linkchecker', 'Loading block %bid for update failed. Manual fix required.', array('%bid' => $block_custom->delta), WATCHDOG_ERROR);
+            linkchecker_watchdog_log('linkchecker', 'Loading block %bid for update failed. Manual fix required.', array('%bid' => $block_custom->delta), RfcLogLevel::ERROR);
           }
         }
 
@@ -713,25 +755,27 @@ function _linkchecker_status_handling(&$response, $link) {
         $accountSwitcher->switchBack();
       }
       else {
-        linkchecker_watchdog_log('linkchecker', 'Link %link has changed and needs to be updated.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
+        linkchecker_watchdog_log('linkchecker', 'Link %link has changed and needs to be updated.', array('%link' => $link->url), RfcLogLevel::NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       break;
 
     case 404:
-      db_update('linkchecker_link')
+      $response->error = t('Page not found');
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
-      linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
+      $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', array('attributes' => array('target' => '_blank')));
+      linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), RfcLogLevel::NOTICE,   Drupal::l(t('Broken links'), $linkchecker_report__url));
 
       // If unpublishing limit is reached, unpublish all nodes having this link.
-      $linkchecker_action_status_code_404 = variable_get('linkchecker_action_status_code_404', 0);
+      $linkchecker_action_status_code_404 = \Drupal::config('linkchecker.settings')->get('error.action_status_code_404', 0);
       if ($linkchecker_action_status_code_404 && $linkchecker_action_status_code_404 <= ($link->fail_count + 1)) {
         // Switch anonymous user to an admin.
         $accountSwitcher = Drupal::service('account_switcher');
@@ -744,81 +788,90 @@ function _linkchecker_status_handling(&$response, $link) {
     case 405:
       // - 405: Special error handling if method is not allowed. Switch link
       //   checking to GET method and try again.
-      db_update('linkchecker_link')
+
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'method' => 'GET',
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
-      linkchecker_watchdog_log('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'));
+      $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', array('attributes' => array('target' => '_blank')));
+      linkchecker_watchdog_log('linkchecker', 'Method HEAD is not allowed for link %link. Method has been changed to GET.', array('%link' => $link->url), RfcLogLevel::NOTICE,   Drupal::l(t('Broken links'), $linkchecker_report__url));
+
+
       break;
 
     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_update('linkchecker_link')
+         \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
-        linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), WATCHDOG_NOTICE, l(t('Broken links'), 'admin/reports/linkchecker'));
+        $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', array('attributes' => array('target' => '_blank')));
+        linkchecker_watchdog_log('linkchecker', 'Broken link %link has been found.', array('%link' => $link->url), RfcLogLevel::NOTICE,   Drupal::l(t('Broken links'), $linkchecker_report__url));
+
+
       }
       else {
-        db_update('linkchecker_link')
+        \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $link->lid)
-        ->fields(array(
+        ->fields([
           'method' => 'GET',
           'code' => $response->code,
           'error' => $response->error,
           'fail_count' => 0,
           'last_checked' => time(),
-        ))
+        ])
         ->expression('fail_count', 'fail_count + 1')
         ->execute();
 
-        linkchecker_watchdog_log('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'));
+        $linkchecker_report__url = Url::fromRoute('linkchecker.admin_report_page', array('attributes' => array('target' => '_blank')));
+        linkchecker_watchdog_log('linkchecker', 'Internal server error for link %link. Method has been changed to GET.', array('%link' => $link->url), RfcLogLevel::NOTICE,   Drupal::l(t('Broken links'), $linkchecker_report__url));
+
       }
       break;
 
     default:
       // Don't treat ignored response codes as errors.
       if (in_array($response->code, $ignore_response_codes)) {
-        db_update('linkchecker_link')
+        \Drupal::database()->update('linkchecker_link')
           ->condition('lid', $link->lid)
-          ->fields(array(
+          ->fields([
             'code' => $response->code,
             'error' => $response->error,
             'fail_count' => 0,
             'last_checked' => time(),
-          ))
+          ])
           ->execute();
-        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
+        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), RfcLogLevel::ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
       else {
-        db_update('linkchecker_link')
+       \Drupal::database()->update('linkchecker_link')
           ->condition('lid', $link->lid)
-          ->fields(array(
+          ->fields([
             'code' => $response->code,
             'error' => $response->error,
             'fail_count' => 0,
             'last_checked' => time(),
-          ))
+          ])
           ->expression('fail_count', 'fail_count + 1')
           ->execute();
-        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
+        // linkchecker_watchdog_log('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), RfcLogLevel::ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
   }
 
@@ -830,20 +883,29 @@ function _linkchecker_status_handling(&$response, $link) {
  * @fixme: remove after migration
  * Implements hook_node_type_delete().
  */
+
+
 function linkchecker_node_type_delete($info) {
-  variable_del('linkchecker_scan_node_' . $info->type);
-  variable_del('linkchecker_scan_comment_' . $info->type);
+  //variable_del('linkchecker_scan_node_' . $info->type);
+  //variable_del('linkchecker_scan_comment_' . $info->type);
+  //Drupal::configFactory()->getEditable('linkchecker_scan_node_' . $info->type)->delete();
+  //Drupal::configFactory()->getEditable('linkchecker_scan_comment_' . $info->type)->delete();
 }
 
+
+
 /**
  * Implements hook_node_prepare().
  */
 function linkchecker_node_prepare($node) {
   // Node edit tab is viewed.
-  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit' && isset($node->nid)) {
+  $nid =$node->id();
+  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit' && isset($nid)) {
     // Show a message on node edit page if a link check failed once or more.
-    $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
-    $links = db_query('SELECT ll.* FROM {linkchecker_node} ln INNER JOIN {linkchecker_link} ll ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':nid' => $node->nid, ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+    //$links = db_query('SELECT ll.* FROM {linkchecker_node} ln INNER JOIN {linkchecker_link} ll ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':nid' => $node->id(), ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+    $connection = \Drupal::database();
+    $links = $connection->query('SELECT ll.* FROM {linkchecker_node} ln INNER JOIN {linkchecker_link} ll ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', array(':nid' => $node->id(), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes));
     foreach ($links as $link) {
       if (_linkchecker_link_access($link)) {
         drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', array('@url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
@@ -856,7 +918,7 @@ function linkchecker_node_prepare($node) {
  * Implements hook_node_delete().
  */
 function linkchecker_node_delete($node) {
-  _linkchecker_delete_node_links($node->nid);
+  _linkchecker_delete_node_links($node->id());
 }
 
 /**
@@ -866,14 +928,24 @@ function linkchecker_node_insert($node) {
   // Every moderation module saving a forward revision needs to exit here.
   // Please see _linkchecker_isdefaultrevision() for more details.
   // @todo: Refactor this workaround under D8.
-  if (!_linkchecker_isdefaultrevision($node)) {
+
+  if (!$node->isDefaultRevision()) {
     return;
   }
+ //if (!_linkchecker_isdefaultrevision($node)) {
+ //   return;
+ // }
+
 
+  $node_type = \Drupal\node\Entity\NodeType::load($node->getType());
   // The node is going to be published.
-  if (variable_get('linkchecker_scan_node_' . $node->type, FALSE) && $node->status == NODE_PUBLISHED) {
+
+  if ($node_type->getThirdPartySetting('linkchecker', 'scan_node', FALSE) && $node->isPublished()) {
+
     _linkchecker_add_node_links($node);
+
   }
+
 }
 
 /**
@@ -883,12 +955,16 @@ function linkchecker_node_update($node) {
   // Every moderation module saving a forward revision needs to exit here.
   // Please see _linkchecker_isdefaultrevision() for more details.
   // @todo: Refactor this workaround under D8.
-  if (!_linkchecker_isdefaultrevision($node)) {
+  //if (!_linkchecker_isdefaultrevision($node)) {
+  //  return;
+  //}
+  if (!$node->isDefaultRevision()) {
     return;
   }
 
   // The node is going to be published.
-  if (variable_get('linkchecker_scan_node_' . $node->type, FALSE) && $node->status == NODE_PUBLISHED) {
+  $node_type = \Drupal\node\Entity\NodeType::load($node->getType());
+  if ($node_type->getThirdPartySetting('linkchecker', 'scan_node', FALSE) && $node->isPublished()) {
     _linkchecker_add_node_links($node);
   }
   else {
@@ -909,8 +985,9 @@ function linkchecker_comment_delete($comment) {
  */
 function linkchecker_comment_insert($comment) {
   // The comment is going to be published.
-  $node_type = db_query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
-  if (variable_get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
+  $connection = \Drupal::database();
+  $node_type = $connection->query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
     _linkchecker_add_comment_links($comment);
   }
 }
@@ -920,8 +997,10 @@ function linkchecker_comment_insert($comment) {
  */
 function linkchecker_comment_update($comment) {
   // The node is going to be published.
-  $node_type = db_query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
-  if (variable_get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
+  $connection = \Drupal::database();
+  $node_type = $connection->query('SELECT type FROM {node} WHERE nid = :nid', array(':nid' => $comment->nid))->fetchField();
+
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $node_type, FALSE) && $comment->status == COMMENT_PUBLISHED) {
     _linkchecker_add_comment_links($comment);
   }
   else {
@@ -947,7 +1026,8 @@ function linkchecker_form_alter(&$form, FormStateInterface $form_state, $form_id
         // Show a message on custom block edit page if a link check failed once
         // or more often.
         $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes'));
-        $links = db_query('SELECT ll.* FROM {linkchecker_block_custom} lb INNER JOIN {linkchecker_link} ll ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':bid' => arg(5), ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+        $connection = \Drupal::database();
+        $links = $connection->query('SELECT ll.* FROM {linkchecker_block_custom} lb INNER JOIN {linkchecker_link} ll ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', array(':bid' => arg(5), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes));
         foreach ($links as $link) {
           if (_linkchecker_link_access($link)) {
             drupal_set_message(format_plural($link->fail_count, 'Link check of <a href=":url">:url</a> failed once (status code: @code).', 'Link check of <a href=":url">:url</a> failed @count times (status code: @code).', array(':url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
@@ -1050,8 +1130,10 @@ function linkchecker_form_comment_form_alter(&$form, &$form_state, $form_id) {
   if ((empty($form_state['input']) || (isset($form_state['input']['op']) && $form_state['input']['op'] == t('Preview'))) && arg(0) == 'comment' && is_numeric(arg(1)) && arg(2) == 'edit') {
     // Show a message on comment edit page if a link check failed once or
     // more often.
-    $ignore_response_codes = preg_split('/(\r\n?|\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));
-    $links = db_query('SELECT ll.* FROM {linkchecker_comment} lc INNER JOIN {linkchecker_link} ll ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes)', array(':cid' => arg(1), ':fail_count' => 0, ':status' => 1, ':codes' => $ignore_response_codes));
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+
+    $connection = \Drupal::database();
+    $links = $connection->query('SELECT ll.* FROM {linkchecker_comment} lc INNER JOIN {linkchecker_link} ll ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.fail_count > :fail_count AND ll.status = :status AND ll.code NOT IN (:codes[])', array(':cid' => arg(1), ':fail_count' => 0, ':status' => 1, ':codes[]' => $ignore_response_codes));
     foreach ($links as $link) {
       if (_linkchecker_link_access($link)) {
         drupal_set_message(format_plural($link->fail_count, 'Link check of <a href="@url">@url</a> failed once (status code: @code).', 'Link check of <a href="@url">@url</a> failed @count times (status code: @code).', array('@url' => $link->url, '@code' => $link->code)), 'warning', FALSE);
@@ -1064,8 +1146,10 @@ function linkchecker_form_comment_form_alter(&$form, &$form_state, $form_id) {
  * Custom submit handler for block add page.
  */
 function linkchecker_block_custom_add_form_submit($form, &$form_state) {
-  if (variable_get('linkchecker_scan_blocks', 0)) {
-    $bid = db_query('SELECT MAX(bid) FROM {block_custom}')->fetchField();
+  if (\Drupal::config('linkchecker.settings')->get('scan_blocks', 0)) {
+    $connection = \Drupal::database();
+    $bid = $connection->query('SELECT MAX(bid) FROM {block_custom}')->fetchField();
+
     _linkchecker_add_block_custom_links($form_state['values'], $bid);
   }
 }
@@ -1074,7 +1158,7 @@ function linkchecker_block_custom_add_form_submit($form, &$form_state) {
  * Custom submit handler for block configure page.
  */
 function linkchecker_block_custom_configure_form_submit($form, &$form_state) {
-  if (variable_get('linkchecker_scan_blocks', 0)) {
+  if (\Drupal::config('linkchecker.settings')->get('scan_blocks', 0)) {
     _linkchecker_add_block_custom_links($form_state['values'], $form_state['values']['delta']);
   }
 }
@@ -1137,6 +1221,7 @@ function linkchecker_block_custom_block_get($bid) {
  */
 function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
 
+
   $filter = new stdClass();
   $filter->settings['filter_url_length'] = 72;
 
@@ -1146,16 +1231,23 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
 
   // Add fields typically not used for urls to the bottom. This way a link may
   // found earlier while looping over $text_items_by_field below.
-  $text_items_by_field = array_merge($text_items_by_field, _linkchecker_parse_fields('node', $node->type, $node, TRUE));
-  $text_items_by_field['title'][] = _filter_url($node->title, $filter);
+  $link_check = _linkchecker_parse_fields('node', $node->getType(), $node, TRUE);
+
+  $text_items_by_field = array_merge($text_items_by_field, $link_check);
+
+ // $text_items_by_field['title'][] = _filter_url($node->get('title')->value, $filter);
+
   $text_items = _linkchecker_array_values_recursive($text_items_by_field);
 
+
   // Get the absolute node path for extraction of relative links.
-  $languages = language_list();
+  //$languages = language_list();
   // Note: An "undefined language" (value: 'und') isn't listed in the available
   // languages variable $languages.
-  $url_options = (empty($node->language) || empty($languages[$node->language])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language], 'absolute' => TRUE);
-  $path = url('node/' . $node->nid, $url_options);
+
+  $url_options = (empty($node->language()->getId()) || empty($languages[$node->language()->getId()])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language()->getId()], 'absolute' => TRUE);
+
+  $path = \Drupal\Core\Url::fromUri('base:' . 'node/' . $node->id())->toString() ;
 
   // Extract all links in a node.
   $links = _linkchecker_extract_links(implode(' ', $text_items), $path);
@@ -1167,6 +1259,7 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
   }
   else {
     $field_names = array();
+
     foreach ($text_items_by_field as $field_name => $items) {
       foreach ($items as $item) {
         foreach ($links as $uri => $link) {
@@ -1191,7 +1284,9 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
     }
 
     return $field_names;
+
   }
+
 }
 
 /**
@@ -1204,32 +1299,50 @@ function _linkchecker_extract_node_links($node, $return_field_names = FALSE) {
  *   the need for content re-scans is detected by the number of missing links.
  */
 function _linkchecker_add_node_links($node, $skip_missing_links_detection = FALSE) {
+
+
   $links = array_keys(_linkchecker_extract_node_links($node));
 
   // Node have links.
   if (!empty($links)) {
     // Remove all links from the links array already in the database and only
     // add missing links to database.
-    $missing_links = _linkchecker_node_links_missing($node->nid, $links);
+    $missing_links = _linkchecker_node_links_missing($node->id(), $links);
 
     // Only add links to database that do not exists.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = \Drupal\Component\Utility\Crypt::hashBase64($url);
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+
+        $lid = \Drupal::database()->insert('linkchecker_link')
+           ->fields($link)
+           ->execute();
+
+        \Drupal::database()->insert('linkchecker_node')
+            ->fields([
+                'nid' => $node->id(),
+                'lid' => $lid,
+            ])
+            ->execute();
+      }
+      else {
+        $result = \Drupal::database()->query("SELECT * FROM {linkchecker_node} WHERE nid = :nid AND lid = :lid", [':nid' => $node->id(), ':lid' => $link->lid])->fetchAll();
+        if (!$result) {
+          \Drupal::database()->insert('linkchecker_node')
+              ->fields([
+                  'nid' => $node->id(),
+                  'lid' => $link->lid,
+              ])
+              ->execute();
+        }
       }
-      db_insert('linkchecker_node')
-        ->fields(array(
-          'nid' => $node->nid,
-          'lid' => $link->lid,
-        ))
-        ->execute();
 
       // Break processing if max links limit per run has been reached.
       $i++;
@@ -1254,20 +1367,21 @@ function _linkchecker_add_node_links($node, $skip_missing_links_detection = FALS
     $missing_links_count = count($missing_links) - LINKCHECKER_SCAN_MAX_LINKS_PER_RUN;
     if (!$skip_missing_links_detection && $missing_links_count > 0) {
       module_load_include('inc', 'linkchecker', 'linkchecker.batch');
-      batch_set(_linkchecker_batch_import_single_node($node->nid, $missing_links_count));
+      batch_set(_linkchecker_batch_import_single_node($node->id(), $missing_links_count));
 
       // If batches were set in the submit handlers, we process them now,
       // possibly ending execution. We make sure we do not react to the batch
       // that is already being processed (if a batch operation performs a
       // drupal_execute).
       if ($batch = &batch_get() && !isset($batch['current_set'])) {
-        batch_process('node/' . $node->nid);
+        batch_process('node/' . $node->id());
       }
     }
   }
 
   // Remove dead link references for cleanup reasons as very last step.
-  _linkchecker_cleanup_node_references($node->nid, $links);
+ _linkchecker_cleanup_node_references($node->id(), $links);
+
 }
 
 /**
@@ -1290,9 +1404,9 @@ function _linkchecker_add_comment_links($comment, $skip_missing_links_detection
   $text_items = array_merge($text_items, _linkchecker_parse_fields('comment', $comment->node_type, $comment));
 
   // Get the absolute node path for extraction of relative links.
-  $languages = language_list();
-  $node = node_load($comment->nid);
-  $url_options = (empty($node->language) || empty($languages[$node->language])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language], 'absolute' => TRUE);
+  $languages =  \Drupal::languageManager()->getLanguages();
+  $node = Node::load($comment->nid);
+  $url_options = (empty($node->language()->getId()) || empty($languages[$node->language()->getId()])) ? array('absolute' => TRUE) : array('language' => $languages[$node->language()->getId()], 'absolute' => TRUE);
   $path = url('node/' . $comment->nid, $url_options);
 
   // Extract all links in a comment.
@@ -1307,20 +1421,26 @@ function _linkchecker_add_comment_links($comment, $skip_missing_links_detection
     // Only add unique links to database that do not exist.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = \Drupal\Component\Utility\Crypt::hashBase64($url);
+
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+        //drupal_write_record('linkchecker_link', $link);
+        $lid = \Drupal::database()->insert('linkchecker_link')
+            ->fields($link)
+            ->execute();
+
       }
-      db_insert('linkchecker_comment')
-        ->fields(array(
+      \Drupal::database()->insert('linkchecker_comment')
+        ->fields([
           'cid' => $comment->cid,
-          'lid' => $link->lid,
-        ))
+          'lid' => $lid ? $lid : $link->lid,
+        ])
         ->execute();
 
       // Break processing if max links limit per run has been reached.
@@ -1411,20 +1531,25 @@ function _linkchecker_add_block_custom_links($block_custom, $bid, $skip_missing_
     // Only add unique links to database that do not exist.
     $i = 0;
     foreach ($missing_links as $url) {
-      $urlhash = drupal_hash_base64($url);
-      $link = db_query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
+      $urlhash = \Drupal\Component\Utility\Crypt::hashBase64($url);
+
+      $connection = \Drupal::database();
+      $link = $connection->query('SELECT lid FROM {linkchecker_link} WHERE urlhash = :urlhash', array(':urlhash' => $urlhash))->fetchObject();
       if (!$link) {
-        $link = new stdClass();
-        $link->urlhash = $urlhash;
-        $link->url = $url;
-        $link->status = _linkchecker_link_check_status_filter($url);
-        drupal_write_record('linkchecker_link', $link);
+        $link = [];
+        $link['urlhash'] = $urlhash;
+        $link['url'] = $url;
+        $link['status'] = _linkchecker_link_check_status_filter($url);
+        //drupal_write_record('linkchecker_link', $link);
+        $lid = \Drupal::database()->insert('linkchecker_block_custom')
+          ->fields($link)
+          ->execute();
       }
-      db_insert('linkchecker_block_custom')
-        ->fields(array(
+       \Drupal::database()->insert('linkchecker_block_custom')
+        ->fields([
           'bid' => $bid,
-          'lid' => $link->lid,
-        ))
+          'lid' => $lid ? $lid :$link->lid,
+        ])
         ->execute();
 
       // Break processing if max links limit per run has been reached.
@@ -1473,7 +1598,7 @@ function _linkchecker_add_block_custom_links($block_custom, $bid, $skip_missing_
  *   The node ID.
  */
 function _linkchecker_delete_node_links($nid) {
-  db_delete('linkchecker_node')
+  \Drupal::database()->delete('linkchecker_node')
     ->condition('nid', $nid)
     ->execute();
 }
@@ -1485,7 +1610,7 @@ function _linkchecker_delete_node_links($nid) {
  *   The comment ID.
  */
 function _linkchecker_delete_comment_links($cid) {
-  db_delete('linkchecker_comment')
+  \Drupal::database()->delete('linkchecker_comment')
     ->condition('cid', $cid)
     ->execute();
 }
@@ -1498,7 +1623,7 @@ function _linkchecker_delete_comment_links($cid) {
  *
  */
 function _linkchecker_delete_block_custom_links($bid) {
-  db_delete('linkchecker_block_custom')
+  \Drupal::database()->delete('linkchecker_block_custom')
     ->condition('bid', $bid)
     ->execute();
 }
@@ -1513,7 +1638,7 @@ function _linkchecker_delete_block_custom_links($bid) {
 function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
   if (empty($links)) {
     // Node do not have links. Delete all references if exists.
-    db_delete('linkchecker_node')
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $nid)
       ->execute();
   }
@@ -1521,11 +1646,12 @@ function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
     // The node still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_node reference table.
-    $subquery = db_select('linkchecker_link')
-      ->fields('linkchecker_link', array('lid'))
-      ->condition('urlhash', array_map('drupal_hash_base64', $links), 'IN');
 
-    db_delete('linkchecker_node')
+    $subquery = \Drupal::database()->select('linkchecker_link')
+      ->fields('linkchecker_link', ['lid'])
+      ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
+
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $nid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1542,7 +1668,7 @@ function _linkchecker_cleanup_node_references($nid = 0, $links = array()) {
 function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
   if (empty($links)) {
     // Comment do not have links. Delete all references if exists.
-    db_delete('linkchecker_comment')
+    \Drupal::database()->delete('linkchecker_comment')
       ->condition('cid', $cid)
       ->execute();
   }
@@ -1550,11 +1676,11 @@ function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
     // The comment still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_comment reference table.
-    $subquery = db_select('linkchecker_link', 'll')
+    $subquery = \Drupal::database()->select('linkchecker_link', 'll')
       ->fields('ll', array('lid'))
-      ->condition('ll.urlhash', array_map('drupal_hash_base64', $links), 'IN');
+      ->condition('ll.urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
 
-    db_delete('linkchecker_comment')
+    \Drupal::database()->delete('linkchecker_comment')
       ->condition('cid', $cid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1571,7 +1697,8 @@ function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
 function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()) {
   if (empty($links)) {
     // Block do not have links. Delete all references if exists.
-    db_delete('linkchecker_block_custom')
+
+    \Drupal::database()->delete('linkchecker_block_custom')
       ->condition('bid', $bid)
       ->execute();
   }
@@ -1579,11 +1706,12 @@ function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()
     // The block still have more than one link, but other links may have been
     // removed and links no longer in the content need to be deleted from the
     // linkchecker_block_custom reference table.
-    $subquery = db_select('linkchecker_link')
+
+    $subquery = \Drupal::database()->select('linkchecker_link')
       ->fields('linkchecker_link', array('lid'))
-      ->condition('urlhash', array_map('drupal_hash_base64', $links), 'IN');
+      ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links), 'IN');
 
-    db_delete('linkchecker_block_custom')
+    \Drupal::database()->delete('linkchecker_block_custom')
       ->condition('bid', $bid)
       ->condition('lid', $subquery, 'NOT IN')
       ->execute();
@@ -1602,7 +1730,11 @@ function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()
  *   An array of node references missing in the linkchecker_node table.
  */
 function _linkchecker_node_links_missing($nid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_node} ln ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.urlhash IN (:urlhashes)', array(':nid' => $nid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
+
+  $connection = \Drupal::database();
+
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_node} ln ON ln.lid = ll.lid WHERE ln.nid = :nid AND ll.urlhash IN (:urlhashes[])', [':nid' => $nid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)]);
+
   $links_in_database = array();
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
@@ -1622,7 +1754,10 @@ function _linkchecker_node_links_missing($nid, $links) {
  *   An array of comment references missing in the linkchecker_comment table.
  */
 function _linkchecker_comment_links_missing($cid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_comment} lc ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.urlhash IN (:urlhashes)', array(':cid' => $cid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
+
+   $connection = \Drupal::database();
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_comment} lc ON lc.lid = ll.lid WHERE lc.cid = :cid AND ll.urlhash IN (:urlhashes[])', array(':cid' => $cid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)));
+
   $links_in_database = array();
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
@@ -1643,7 +1778,9 @@ function _linkchecker_comment_links_missing($cid, $links) {
  *   table.
  */
 function _linkchecker_block_custom_links_missing($bid, $links) {
-  $result = db_query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_block_custom} lb ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.urlhash IN (:urlhashes)', array(':bid' => $bid, ':urlhashes' => array_map('drupal_hash_base64', $links)));
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT ll.url FROM {linkchecker_link} ll INNER JOIN {linkchecker_block_custom} lb ON lb.lid = ll.lid WHERE lb.bid = :bid AND ll.urlhash IN (:urlhashes[])', array(':bid' => $bid, ':urlhashes[]' => array_map('\Drupal\Component\Utility\Crypt::hashBase64', $links)));
+
   $links_in_database = array();
   foreach ($result as $row) {
     $links_in_database[] = $row->url;
@@ -1672,6 +1809,7 @@ function _linkchecker_block_custom_links_missing($bid, $links) {
  *   Array of field items with filters applied.
  */
 function _linkchecker_parse_fields($entity_type, $bundle_name, $entity, $return_field_names = FALSE) {
+
   $text_items = array();
   $text_items_by_field = array();
 
@@ -1680,55 +1818,67 @@ function _linkchecker_parse_fields($entity_type, $bundle_name, $entity, $return_
   $filter->settings['filter_url_length'] = 72;
 
   // Collect the fields from this entity_type and bundle.
-  foreach (field_info_instances($entity_type, $bundle_name) as $field_name => $instance) {
-    $field = field_info_field($field_name);
-    // #1923328: field_name array may be missing in $entity.
-    $entity_field = isset($entity->{$field['field_name']}) ? $entity->{$field['field_name']} : array();
 
-    switch ($field['type']) {
-      // Core fields.
-      case 'text_with_summary':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
+  $entityManager = \Drupal::service('entity_field.manager');
+  $fields = $entityManager->getFieldDefinitions($entity_type, $bundle_name);
+
+  foreach ($fields as $field_name => $instance) {
+    if ($instance instanceof FieldConfigInterface ) {
+      $field =  \Drupal\field\Entity\FieldStorageConfig::loadByName($entity_type, $field_name);
+      // #1923328: field_name array may be missing in $entity.
+      $entity_field = isset($entity->{$field->getName()}) ? $entity->{$field->getName()} : array();
+
+      switch ($field->getType()) {
+        // Core fields.
+        case 'text_with_summary':
+
+         // foreach ($entity_field as $value) {
+          $field_value =  $entity_field->getValue();
+          foreach ($field_value as $item) {
+
             $item += array(
-              'format' => NULL,
-              'summary' => '',
-              'value' => '',
+                'format' => NULL,
+                'summary' => '',
+                'value' => '',
             );
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['summary'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['summary'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
           }
-        }
-        break;
+          break;
 
-      // Core fields.
-      case 'text_long':
-      case 'text':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
-            $item += array(
-              'format' => NULL,
-              'value' => '',
-            );
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
+        // Core fields.
+        case 'text_long':
+        case 'text':
+        case 'string':
+        case 'string_long':
+         $field_value =  $entity_field->getValue();
+
+          foreach ($field_value as $item) {
+              $item += array(
+                  'format' => NULL,
+                  'value' => '',
+              );
+            $text_items[] = $text_items_by_field[$field->getName()][] = _linkchecker_check_markup($item['value'], $item['format'], linkchecker_entity_language($entity_type, $entity), TRUE);
           }
-        }
-        break;
+          break;
 
-      // Link module field, http://drupal.org/project/link.
-      case 'link_field':
-        foreach ($entity_field as $language) {
-          foreach ($language as $item) {
-            $item += array(
-              'title' => '',
-            );
-            $options = drupal_parse_url(link_cleanup_url($item['url']));
-            $text_items[] = $text_items_by_field[$field['field_name']][] = l($item['title'], $options['path'], $options);
-            $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['title'], NULL, linkchecker_entity_language($entity_type, $entity), TRUE);
+        // Link module field, http://drupal.org/project/link.
+        case 'link_field':
+          foreach ($entity_field as $language) {
+            foreach ($language as $item) {
+              $item += array(
+                  'title' => '',
+              );
+              $options = drupal_parse_url(link_cleanup_url($item['url']));
+              $text_items[] = $text_items_by_field[$field['field_name']][] = l($item['title'], $options['path'], $options);
+              $text_items[] = $text_items_by_field[$field['field_name']][] = _linkchecker_check_markup($item['title'], NULL, linkchecker_entity_language($entity_type, $entity), TRUE);
+            }
           }
-        }
-        break;
+          break;
+      }
     }
+
   }
 
   return ($return_field_names) ? $text_items_by_field : $text_items;
@@ -1802,11 +1952,13 @@ function _linkchecker_cleanup_links() {
   // Remove disabled node types no longer in use.
   $node_types = linkchecker_scan_node_types();
   if (!empty($node_types)) {
-    $subquery1 = db_select('node', 'n')
+
+    $subquery1 = \Drupal::database()->select('node', 'n')
+
       ->fields('n', array('nid'))
       ->condition('n.type', $node_types, 'NOT IN');
 
-    db_delete('linkchecker_node')
+    \Drupal::database()->delete('linkchecker_node')
       ->condition('nid', $subquery1, 'IN')
       ->execute();
 
@@ -1815,7 +1967,8 @@ function _linkchecker_cleanup_links() {
   }
   else {
     // No active node_type. Remove all items from table.
-    db_truncate('linkchecker_node')->execute();
+    //db_truncate('linkchecker_node')->execute();
+     \Drupal::database()->truncate('linkchecker_node')->execute();
     // @todo Remove comments link references from table.
   }
 
@@ -1823,31 +1976,35 @@ function _linkchecker_cleanup_links() {
   // @todo Remove comments of unpublished nodes.
   $comment_types = linkchecker_scan_comment_types();
   if (empty($comment_types)) {
-    db_truncate('linkchecker_comment')->execute();
+    \Drupal::database()->truncate('linkchecker_comment')->execute();
   }
 
   // Remove block link references if block scanning is disabled.
-  if (variable_get('linkchecker_scan_blocks', 0) == 0) {
-    db_truncate('linkchecker_block_custom')->execute();
+  if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_blocks', 0) == 0) {
+    \Drupal::database()->truncate('linkchecker_block_custom')->execute();
   }
 
   // Remove dead links without references.
-  $linkchecker_node = db_select('linkchecker_node', 'ln')
+
+  $linkchecker_node = \Drupal::database()->select('linkchecker_node', 'ln')
+
     ->distinct()
     ->fields('ln', array('lid'));
-  $linkchecker_comment = db_select('linkchecker_comment', 'lc')
+
+  $linkchecker_comment = \Drupal::database()->select('linkchecker_comment', 'lc')
     ->distinct()
     ->fields('lc', array('lid'));
-  $linkchecker_block_custom = db_select('linkchecker_block_custom', 'lb')
+
+  $linkchecker_block_custom = \Drupal::database()->select('linkchecker_block_custom', 'lb')
     ->distinct()
     ->fields('lb', array('lid'));
 
   // UNION all linkchecker type tables.
-  $subquery2 = db_select($linkchecker_block_custom->union($linkchecker_comment)->union($linkchecker_node), 'q1')
+  $subquery2  = \Drupal::database()->select($linkchecker_block_custom->union($linkchecker_comment)->union($linkchecker_node), 'q1')
     ->distinct()
     ->fields('q1', array('lid'));
 
-  db_delete('linkchecker_link')
+  \Drupal::database()->delete('linkchecker_link')
     ->condition('lid', $subquery2, 'NOT IN')
     ->execute();
 
@@ -1871,12 +2028,12 @@ function _linkchecker_cleanup_links() {
 function _linkchecker_extract_links($text = '', $content_path = NULL) {
   global $base_root, $is_https;
 
-  $html_dom = filter_dom_load($text);
+  $html_dom = Html::load($text);
   $urls = array();
-
   // Finds all hyperlinks in the content.
-  if (variable_get('linkchecker_extract_from_a', 1) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_a', 1) == 1) {
     $links = $html_dom->getElementsByTagName('a');
+
     foreach ($links as $link) {
       $urls[] = $link->getAttribute('href');
     }
@@ -1888,7 +2045,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds all audio links in the content.
-  if (variable_get('linkchecker_extract_from_audio', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_audio', 0) == 1) {
     $audios = $html_dom->getElementsByTagName('audio');
     foreach ($audios as $audio) {
       $urls[] = $audio->getAttribute('src');
@@ -1907,7 +2064,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds embed tags with links in the content.
-  if (variable_get('linkchecker_extract_from_embed', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_embed', 0) == 1) {
     $embeds = $html_dom->getElementsByTagName('embed');
     foreach ($embeds as $embed) {
       $urls[] = $embed->getAttribute('src');
@@ -1917,7 +2074,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds iframe tags with links in the content.
-  if (variable_get('linkchecker_extract_from_iframe', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_iframe', 0) == 1) {
     $iframes = $html_dom->getElementsByTagName('iframe');
     foreach ($iframes as $iframe) {
       $urls[] = $iframe->getAttribute('src');
@@ -1925,7 +2082,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds img tags with links in the content.
-  if (variable_get('linkchecker_extract_from_img', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_img', 0) == 1) {
     $imgs = $html_dom->getElementsByTagName('img');
     foreach ($imgs as $img) {
       $urls[] = $img->getAttribute('src');
@@ -1934,7 +2091,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds object/param tags with links in the content.
-  if (variable_get('linkchecker_extract_from_object', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_object', 0) == 1) {
     $objects = $html_dom->getElementsByTagName('object');
     foreach ($objects as $object) {
       $urls[] = $object->getAttribute('data');
@@ -1960,7 +2117,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   }
 
   // Finds video tags with links in the content.
-  if (variable_get('linkchecker_extract_from_video', 0) == 1) {
+  if (\Drupal::config('linkchecker.settings')->get('extract.from_video', 0) == 1) {
     $videos = $html_dom->getElementsByTagName('video');
     foreach ($videos as $video) {
       $urls[] = $video->getAttribute('poster');
@@ -1983,9 +2140,8 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
   $urls = array_filter($urls);
   // Remove duplicate urls.
   $urls = array_unique($urls);
-
   // What type of links should be checked?
-  $linkchecker_check_links_types = variable_get('linkchecker_check_links_types', 1);
+  $linkchecker_check_links_types = \Drupal::config('linkchecker.settings')->get('check_links_types', 1);
 
   $links = array();
   foreach ($urls as $url) {
@@ -2005,7 +2161,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
     $url_encoded = str_replace(' ', '%20', $url_decoded);
 
     // Full qualified URLs.
-    if ($linkchecker_check_links_types != 2 && valid_url($url_encoded, TRUE)) {
+    if ($linkchecker_check_links_types != 2 && UrlHelper::isValid($url_encoded, TRUE)) {
       // Add to Array and change HTML links into plain text links.
       $links[$url_decoded][] = $url;
     }
@@ -2014,7 +2170,7 @@ function _linkchecker_extract_links($text = '', $content_path = NULL) {
       continue;
     }
     // Local URLs. $linkchecker_check_links_types = 0 or 2
-    elseif ($linkchecker_check_links_types != 1 && valid_url($url_encoded, FALSE)) {
+    elseif ($linkchecker_check_links_types != 1 && UrlHelper::isValid($url_encoded, FALSE)) {
       // Get full qualified url with base path of content.
       $absolute_content_path = _linkchecker_absolute_content_path($content_path);
 
@@ -2081,17 +2237,17 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
   if (!empty($text) && !empty($old_link_fqdn) && !empty($new_link_fqdn)) {
     // Remove protocols and hostname from local URLs.
     $base_roots = array(
-      drupal_strtolower('http://' . $_SERVER['HTTP_HOST']),
-      drupal_strtolower('https://' . $_SERVER['HTTP_HOST']),
+        Unicode::strtolower('http://' . $_SERVER['HTTP_HOST']),
+        Unicode::strtolower('https://' . $_SERVER['HTTP_HOST']),
     );
     $old_link = str_replace($base_roots, '', $old_link_fqdn);
     $new_link = str_replace($base_roots, '', $new_link_fqdn);
 
     // Build variables with all URLs and run check_url() only once.
-    $old_html_link_fqdn = check_url($old_link_fqdn);
-    $new_html_link_fqdn = check_url($new_link_fqdn);
-    $old_html_link = check_url($old_link);
-    $new_html_link = check_url($new_link);
+    $old_html_link_fqdn = UrlHelper::filterBadProtocol($old_link_fqdn);
+    $new_html_link_fqdn = UrlHelper::filterBadProtocol($new_link_fqdn);
+    $old_html_link = UrlHelper::filterBadProtocol($old_link);
+    $new_html_link = UrlHelper::filterBadProtocol($new_link);
 
     // Replace links in link fields and text and Links weblink fields.
     if (in_array($text, array($old_html_link_fqdn, $old_html_link, $old_link_fqdn, $old_link))) {
@@ -2117,10 +2273,10 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       $old_links = array_unique($old_links);
 
       // Load HTML code into DOM.
-      $html_dom = filter_dom_load($text);
+      $html_dom = Html::load($text);
 
       // Finds all hyperlinks in the content.
-      if (variable_get('linkchecker_extract_from_a', 1) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_a', 1) == 1) {
         $links = $html_dom->getElementsByTagName('a');
         foreach ($links as $link) {
           if (in_array($link->getAttribute('href'), $old_links)) {
@@ -2142,7 +2298,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds all audio links in the content.
-      if (variable_get('linkchecker_extract_from_audio', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_a', 0) == 1) {
         $audios = $html_dom->getElementsByTagName('audio');
         foreach ($audios as $audio) {
           if (in_array($audio->getAttribute('src'), $old_links)) {
@@ -2167,7 +2323,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds embed tags with links in the content.
-      if (variable_get('linkchecker_extract_from_embed', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_embed', 0) == 1) {
         $embeds = $html_dom->getElementsByTagName('embed');
         foreach ($embeds as $embed) {
           if (in_array($embed->getAttribute('src'), $old_links)) {
@@ -2183,7 +2339,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds iframe tags with links in the content.
-      if (variable_get('linkchecker_extract_from_iframe', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_iframe', 0) == 1) {
         $iframes = $html_dom->getElementsByTagName('iframe');
         foreach ($iframes as $iframe) {
           if (in_array($iframe->getAttribute('src'), $old_links)) {
@@ -2193,7 +2349,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds img tags with links in the content.
-      if (variable_get('linkchecker_extract_from_img', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_img', 0) == 1) {
         $imgs = $html_dom->getElementsByTagName('img');
         foreach ($imgs as $img) {
           if (in_array($img->getAttribute('src'), $old_links)) {
@@ -2206,7 +2362,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds object/param tags with links in the content.
-      if (variable_get('linkchecker_extract_from_object', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_object', 0) == 1) {
         $objects = $html_dom->getElementsByTagName('object');
         foreach ($objects as $object) {
           if (in_array($object->getAttribute('data'), $old_links)) {
@@ -2240,7 +2396,7 @@ function _linkchecker_link_replace(&$text, $old_link_fqdn = '', $new_link_fqdn =
       }
 
       // Finds video tags with links in the content.
-      if (variable_get('linkchecker_extract_from_video', 0) == 1) {
+      if (\Drupal::config('linkchecker.settings')->get('extract.from_video', 0) == 1) {
         $videos = $html_dom->getElementsByTagName('video');
         foreach ($videos as $video) {
           if (in_array($video->getAttribute('poster'), $old_links)) {
@@ -2287,8 +2443,10 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
     $format_id = filter_fallback_format();
   }
   // If the requested text format does not exist, the text cannot be filtered.
-  if (!$format = filter_format_load($format_id)) {
-    linkchecker_watchdog_log('filter', 'Missing text format: %format.', array('%format' => $format_id), WATCHDOG_ALERT);
+  /** @var \Drupal\filter\Entity\FilterFormat $format **/
+  $format = FilterFormat::load($format_id);
+  if (!$format) {
+    linkchecker_watchdog_log('filter', 'Missing text format: %format.', array('%format' => $format_id), RfcLogLevel::ALERT);
     return '';
   }
 
@@ -2296,40 +2454,54 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
   $cache = $cache && !empty($format->cache);
   $cache_id = '';
   if ($cache) {
-    $cache_id = 'linkchecker:' . $format->format . ':' . $langcode . ':' . hash('sha256', $text);
+    $cache_id = 'linkchecker:' . $format->id() . ':' . $langcode . ':' . hash('sha256', $text);
     if ($cached = cache_get($cache_id, 'cache_filter')) {
       return $cached->data;
     }
   }
 
+
   // Convert all Windows and Mac newlines to a single newline, so filters only
   // need to deal with one possibility.
   $text = str_replace(array("\r\n", "\r"), "\n", $text);
 
+
   // Get a complete list of filters, ordered properly.
-  $filters = filter_list_format($format->format);
-  $filter_info = filter_get_filters();
+  //$filters = filter_list_format($format->format);
+  //$filter_info = filter_get_filters();
+
+  /** @var \Drupal\filter\Plugin\FilterInterface[] $filters **/
+  $filters = $format->filters();
+  $filter_info = filter_formats();
 
   // Do not run placeholder or special tag filters used as references to nodes
   // like 'weblink' or 'weblinks' node types. If the original link node is
-  // updated, all links are automatically up-to-date and there is no need to
+  // updated, all links are automatically2 up-to-date and there is no need to
   // notify about the broken link on all nodes having a link reference in
   // content. This would only confuse the authors as they may also not be able
   // to fix the source node of the reference.
-  $filters_blacklist = array_keys(array_filter(variable_get('linkchecker_filter_blacklist', explode('|', LINKCHECKER_DEFAULT_FILTER_BLACKLIST))));
+
+  $filters_blacklist = array_keys(array_filter(\Drupal::config('linkchecker.settings')->get('extract.filter_blacklist', explode('|', LINKCHECKER_DEFAULT_FILTER_BLACKLIST))));
 
   // Give filters the chance to escape HTML-like data such as code or formulas.
-  foreach ($filters as $name => $filter) {
+
+  foreach ($filters->getAll() as $filter) {
+
+    $name = $filter->getType();
+    $status = $filter->status;
+
     if (!in_array($name, $filters_blacklist)) {
-      if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
+      if ($status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
         $function = $filter_info[$name]['prepare callback'];
-        $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
+        $text = $function($text, $filters, $format, $langcode, $cache, $cache_id);
       }
     }
   }
 
+
   // Perform filtering.
-  foreach ($filters as $name => $filter) {
+
+  foreach ($filters->getAll() as $name => $filter) {
     if (!in_array($name, $filters_blacklist)) {
       if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) {
         $function = $filter_info[$name]['process callback'];
@@ -2338,11 +2510,14 @@ function _linkchecker_check_markup($text, $format_id = NULL, $langcode = '', $ca
     }
   }
 
+
   // Store in cache with a minimum expiration time of 1 day.
   if ($cache) {
     cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24));
   }
 
+
+
   return $text;
 }
 
@@ -2393,17 +2568,17 @@ function _linkchecker_absolute_content_path($url) {
  * Verifies against blacklists, if the link status should be checked or not.
  */
 function _linkchecker_link_check_status_filter($url) {
-  $status = TRUE;
+  $status = 1;
 
   // Is url in domain blacklist?
-  $urls = variable_get('linkchecker_disable_link_check_for_urls', LINKCHECKER_RESERVED_DOCUMENTATION_DOMAINS);
+  $urls = \Drupal::config('linkchecker.settings')->get('check.disable_link_check_for_urls', LINKCHECKER_RESERVED_DOCUMENTATION_DOMAINS);
   if (!empty($urls) && preg_match('/' . implode('|', array_map(create_function('$links', 'return preg_quote($links, \'/\');'), preg_split('/(\r\n?|\n)/', $urls))) . '/', $url)) {
-    $status = FALSE;
+    $status = 0;
   }
 
   // Protocol whitelist check (without curl, only http/https is supported).
   if (!preg_match('/^(https?):\/\//i', $url)) {
-    $status = FALSE;
+    $status = 1;
   }
 
   return $status;
@@ -2475,7 +2650,7 @@ function _linkchecker_isvalid_response_code($code) {
 function linkchecker_scan_node_types() {
   $types = array();
   foreach (node_type_get_names() as $type => $name) {
-    if (variable_get('linkchecker_scan_node_' . $type, FALSE)) {
+    if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_node_' . $type, FALSE)) {
       $types[$type] = $type;
     }
   }
@@ -2491,7 +2666,7 @@ function linkchecker_scan_node_types() {
 function linkchecker_scan_comment_types() {
   $types = array();
   foreach (node_type_get_names() as $type => $name) {
-    if (variable_get('linkchecker_scan_comment_' . $type, FALSE)) {
+    if (\Drupal::config('linkchecker.settings')->get('linkchecker_scan_comment_' . $type, FALSE)) {
       $types[$type] = $type;
     }
   }
@@ -2505,16 +2680,18 @@ function linkchecker_scan_comment_types() {
  *   A link ID that have reached a defined failcount.
  */
 function _linkchecker_unpublish_nodes($lid) {
-  $result = db_query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $lid));
+  $connection = \Drupal::database();
+  $result = $connection->query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(':lid' => $lid));
+
   foreach ($result as $row) {
-    // Explicitly don't use node_load_multiple() or the module may run
+    // Explicitly don't use Node::load_multiple() or the module may run
     // into issues like http://drupal.org/node/1210606. With this logic
     // nodes can be updated until an out of memory occurs and further
     // updates will be made on the remaining nodes only.
-    $node = node_load($row->nid);
-    $node->status = NODE_NOT_PUBLISHED;
-    node_save($node);
-    linkchecker_watchdog_log('linkchecker', 'Set @type %title to unpublished.', array('@type' => $node->type, '%title' => $node->title));
+    $node = Node::load($row->nid);
+    $node->setPublished(FALSE);
+    $node->save();
+    linkchecker_watchdog_log('linkchecker', 'Set @type %title to unpublished.', array('@type' => $node->bundle(), '%title' => $node->get('title')->value));
   }
 }
 
@@ -2527,7 +2704,9 @@ function _linkchecker_unpublish_nodes($lid) {
  * @return object
  */
 function linkchecker_link_load($lid) {
-  return db_query('SELECT * FROM {linkchecker_link} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
+  $connection = \Drupal::database();
+  return $connection->query('SELECT * FROM {linkchecker_link} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
+
 }
 
 /**
@@ -2558,13 +2737,13 @@ function _linkchecker_isdefaultrevision($entity) {
   //
   // Every moderation module saving a forward revision needs to return FALSE.
   // @todo: Refactor this workaround under D8.
-
   // Workbench Moderation module.
-  if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type) === TRUE && empty($entity->workbench_moderation['updating_live_revision'])) {
-    return FALSE;
-  }
+   // if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type) === TRUE && empty($entity->workbench_moderation['updating_live_revision'])) {
+   // if (\Drupal::moduleHandler()->moduleExists('workbench_moderation') && ($entity->hasHandlerClass('moderation')) && empty($entity->workbench_moderation['updating_live_revision'])) {
+  //   return FALSE;
+  // }
 
-  return TRUE;
+  //return TRUE;
 }
 
 /**
diff --git a/linkchecker.redirect.inc b/linkchecker.redirect.inc
index 0b1ea20..3f8bf27 100644
--- a/linkchecker.redirect.inc
+++ b/linkchecker.redirect.inc
@@ -4,7 +4,7 @@
  * @file
  * Redirect interface to linkchecker functionalities.
  */
-
+use Drupal\Core\Url;
 /**
  * Implements hook_redirect_insert().
  */
@@ -17,14 +17,13 @@ function linkchecker_redirect_insert($redirect) {
  */
 function linkchecker_redirect_update($redirect) {
   // It's unknown if this is a redirect for HTTP/HTTPS or the encoded urls.
-  $url_http = url($redirect->source, array('absolute' => TRUE, $redirect->source_options));
-  $url_https = url($redirect->source, array('absolute' => TRUE, 'https' => TRUE, $redirect->source_options));
-
+  $url_http = Url::fromUri('internal:' . $redirect->source);
+  $url_https = Url::fromUri('internal:' . $redirect->source, array('https' => TRUE));
   $urls = array(
-    $url_http,
-    $url_https,
-    rawurldecode($url_http),
-    rawurldecode($url_https),
+    $url_http->toString(),
+    $url_https->toString(),
+    rawurldecode($url_http->toString()),
+    rawurldecode($url_https->toString()),
   );
 
   _linkchecker_redirect_reset($urls);
@@ -38,9 +37,8 @@ function linkchecker_redirect_update($redirect) {
  */
 function _linkchecker_redirect_reset($urls = array()) {
   $urls = array_unique($urls);
-
-  $num_updated = db_update('linkchecker_link')
-    ->condition('urlhash', array_map('drupal_hash_base64', $urls))
+  $num_updated = \Drupal::database()->update('linkchecker_link')
+    ->condition('urlhash', array_map('\Drupal\Component\Utility\Crypt::hashBase64', $urls))
     ->condition('fail_count', 0, '>')
     ->condition('status', 1)
     ->fields(array('last_checked' => 0))
diff --git a/linkchecker.routing.yml b/linkchecker.routing.yml
index a2a43e8..2b54ca8 100644
--- a/linkchecker.routing.yml
+++ b/linkchecker.routing.yml
@@ -34,4 +34,4 @@ linkchecker.edit_link_settings_form:
     _admin_route: TRUE
   requirements:
     _custom_access: '\Drupal\linkchecker\Form\LinkCheckerEditLinkSettingsForm::access'
-    linkchecker_link: \d+
+    linkchecker_link: \d+
\ No newline at end of file
diff --git a/src/Controller/LinkCheckerAdminReportPage.php b/src/Controller/LinkCheckerAdminReportPage.php
index 27cf549..ce3a5ec 100644
--- a/src/Controller/LinkCheckerAdminReportPage.php
+++ b/src/Controller/LinkCheckerAdminReportPage.php
@@ -4,14 +4,195 @@ namespace Drupal\linkchecker\Controller;
 
 use Drupal\Core\Session\AccountInterface;
 use Symfony\Component\HttpFoundation\Request;
+use Drupal\Core\Url;
+use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Core\Controller\ControllerBase;
 
 /**
  * Builds admin broken link report page.
  */
-class LinkCheckerAdminReportPage {
+class LinkCheckerAdminReportPage  extends ControllerBase {
 
   public function content() {
-    return '@TODO';
+
+    $ignore_response_codes = preg_split('/(\r\n?|\n)/', \Drupal::config('linkchecker.settings')->get('error.ignore_response_codes', "200\n206\n302\n304\n401\n403"));
+
+    // Search for broken links in nodes and comments and blocks of all users.
+    // @todo Try to make UNION'ed subselect resultset smaller.
+
+    $subquery4 = \Drupal::database()->select('linkchecker_node', 'ln')
+        ->distinct()
+        ->fields('ln', ['lid']);
+
+
+    $subquery3 = \Drupal::database()->select('linkchecker_comment', 'lc')
+        ->distinct()
+        ->fields('lc', ['lid']);
+
+
+    $subquery2 = \Drupal::database()->select('linkchecker_block_custom', 'lb')
+        ->distinct()
+        ->fields('lb', ['lid']);
+
+    // UNION all linkchecker type tables.
+
+    $subquery1 = \Drupal::database()->select($subquery2->union($subquery3)->union($subquery4), 'q1')->fields('q1', ['lid']);
+
+    // Build pager query.
+
+    $query = \Drupal::database()->select('linkchecker_link', 'll');
+    $query->innerJoin($subquery1, 'q2', 'q2.lid = ll.lid');
+    $query->fields('ll');
+    $query->condition('ll.last_checked', 0, '<>');
+    $query->condition('ll.status', 1);
+    $query->condition('ll.code', $ignore_response_codes, 'NOT IN');
+    $query->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+           ->extend('Drupal\Core\Database\Query\TableSortExtender');
+
+    return $this->_linkchecker_report_page($query);
+
   }
 
+  /**
+   * Builds the HTML report page table with pager.
+   *
+   * @param SelectQueryInterface $query
+   *   The pager query for the report page. Can be per user report or global.
+   * @param object|null $account
+   *   The user account object.
+   *
+   * @return string
+   *   Themed report page.
+   */
+
+   public function _linkchecker_report_page($query, $account = NULL) {
+
+    $connection = \Drupal::database();
+    $links_unchecked = $connection->query('SELECT COUNT(1) FROM {linkchecker_link} WHERE last_checked = :last_checked AND status = :status', [':last_checked' => 0, ':status' => 1])->fetchField();
+
+    if ($links_unchecked > 0) {
+      $links_all = $connection->query('SELECT COUNT(1) FROM {linkchecker_link} WHERE status = :status', [':status' => 1])->fetchField();
+
+      drupal_set_message(\Drupal::translation()->formatPlural($links_unchecked,
+          'There is 1 unchecked link of about @links_all links in the database. Please be patient until all links have been checked via cron.',
+          'There are @count unchecked links of about @links_all links in the database. Please be patient until all links have been checked via cron.',
+          ['@links_all' => $links_all]), 'warning');
+    }
+
+    $header = [
+        ['data' => t('URL'), 'field' => 'url', 'sort' => 'desc'],
+        ['data' => t('Response'), 'field' => 'code', 'sort' => 'desc'],
+        ['data' => t('Error'), 'field' => 'error'],
+        ['data' => t('Operations')],
+    ];
+
+    $result = $query
+        ->range(0, 50)
+        ->execute();
+
+    // Evaluate permission once for performance reasons.
+     $account = \Drupal::currentUser();
+    $access_edit_link_settings = $account->hasPermission('edit link settings');
+    $access_administer_blocks = $account->hasPermission('administer blocks');
+    $access_administer_redirects = $account->hasPermission('administer redirects');
+
+    $rows = [];
+    foreach ($result as $link) {
+      // Get the node, block and comment IDs that refer to this broken link and
+      // that the current user has access to.
+      $cids = _linkchecker_link_comment_ids($link, $account);
+      $bids = _linkchecker_link_block_ids($link);
+
+
+      $nids = $connection->query('SELECT nid  FROM {linkchecker_node} WHERE lid = :lid', [':lid' => $link->lid])->fetchCol();
+
+      // If the user does not have access to see this link anywhere, do not
+      // display it, for reasons explained in _linkchecker_link_access(). We
+      // still need to fill the table row, though, so as not to throw off the
+      // number of items in the pager.
+      if (empty($nids) && empty($cids) && empty($bids)) {
+        $rows[] = array(array('data' => t('Permission restrictions deny you access to this broken link.'), 'colspan' => count($header)));
+        continue;
+      }
+      $links = array();
+
+      // Show links to link settings.
+     // if ($access_edit_link_settings) {
+
+       // $links[] = $this->l(t('Edit link settings'), Url::fromUri('base:' . 'linkchecker/' . $link->lid . '/edit'), array('query' => drupal_get_destination()));
+      //}
+
+      // Show link to nodes having this broken link.
+      foreach ($nids as $nid) {
+        $links[] = $this->l(t('Edit node @node', array('@node' => $nid)), Url::fromUri('base:' . 'node/' . $nid . '/edit'), array('query' => drupal_get_destination()));
+      }
+
+      // Show link to comments having this broken link.
+      $comment_types = linkchecker_scan_comment_types();
+      if (\Drupal::moduleHandler()->moduleExists('comment') && !empty($comment_types)) {
+        foreach ($cids as $cid) {
+          $links[] = $this->l(t('Edit comment @comment', array('@comment' => $cid)), Url::fromUri('base:' . 'comment/' . $cid . '/edit'), array('query' => drupal_get_destination()));
+        }
+      }
+
+      // Show link to blocks having this broken link.
+      if ($access_administer_blocks) {
+        foreach ($bids as $bid) {
+          $links[] = $this->l(t('Edit block @block', array('@block' => $bid)), Url::fromUri('base:' . 'admin/structure/block/manage/block/' . $bid . '/configure') , array('query' => drupal_get_destination()));
+        }
+      }
+
+      // Show link to redirect this broken internal link.
+      if (\Drupal::moduleHandler()->moduleExists('redirect') && $access_administer_redirects  && $this->_linkchecker_is_internal_url($link)) {
+        $links[] = $this->l(t('Create redirection'), Url::fromUri('base:' . 'admin/config/search/redirect/add'), array('query' => array('source' => $link->internal, drupal_get_destination())));
+      }
+
+      // Create table data for output.
+      $items = array(
+          '#theme' => 'item_list',
+          '#items' => $links,
+          '#title' => t(''),
+      );
+
+      $rows[] = array(
+          'data' => array(
+              $this->l(_filter_url_trim($link->url, 60), Url::fromUri($link->url)),
+              $link->code,
+              SafeMarkup::checkPlain($link->error),
+              drupal_render($items),
+          ),
+      );
+    }
+
+    $build['linkchecker_table'] = array(
+        '#theme' => 'table',
+        '#header' => $header,
+        '#rows' => $rows,
+        '#empty' => t('No broken links have been found.'),
+    );
+    $build['linkchecker_pager'] = ['#theme' => 'pager'];
+
+    return $build;
+  }
+
+  /**
+   * Check if the link is an internal URL or not.
+   *
+   * @param object $link
+   *   Link object.
+   *
+   * @return bool
+   *   TRUE if link is internal, otherwise FALSE.
+   */
+  public function _linkchecker_is_internal_url(&$link) {
+    global $base_url;
+
+    if (strpos($link->url, $base_url) === 0) {
+      $link->internal = trim(substr($link->url, strlen($base_url)), " \t\r\n\0\\/");
+      return TRUE;
+    }
+  }
+
+
+
 }
diff --git a/src/Form/LinkCheckerAdminSettingsForm.php b/src/Form/LinkCheckerAdminSettingsForm.php
index f49ae59..676e288 100644
--- a/src/Form/LinkCheckerAdminSettingsForm.php
+++ b/src/Form/LinkCheckerAdminSettingsForm.php
@@ -310,7 +310,8 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
 
     // Validate impersonation user name.
     $linkchecker_impersonate_account = user_load_by_name($form_state->getValue('linkchecker_impersonate_account'));
-    if (empty($linkchecker_impersonate_account->id())) {
+
+    if ($linkchecker_impersonate_account && empty($linkchecker_impersonate_account->id())) {
       $form_state->setErrorByName('linkchecker_impersonate_account', $this->t('User account %name cannot found.', ['%name' => $form_state->getValue('linkchecker_impersonate_account')]));
     }
   }
@@ -380,10 +381,16 @@ class LinkCheckerAdminSettingsForm extends ConfigFormBase {
    * blocks.
    */
   function submitClearAnalyzeLinks(array &$form, FormStateInterface $form_state) {
+    /*
     db_truncate('linkchecker_block_custom')->execute();
     db_truncate('linkchecker_comment')->execute();
     db_truncate('linkchecker_node')->execute();
     db_truncate('linkchecker_link')->execute();
+    */
+    \Drupal::database()->truncate('linkchecker_block_custom')->execute();
+    \Drupal::database()->truncate('linkchecker_comment')->execute();
+    \Drupal::database()->truncate('linkchecker_node')->execute();
+    \Drupal::database()->truncate('linkchecker_link')->execute();
 
     // Start batch and analyze all nodes.
     $node_types = linkchecker_scan_node_types();
diff --git a/src/Form/LinkCheckerEditLinkSettingsForm.php b/src/Form/LinkCheckerEditLinkSettingsForm.php
index d020b06..cfa94dc 100644
--- a/src/Form/LinkCheckerEditLinkSettingsForm.php
+++ b/src/Form/LinkCheckerEditLinkSettingsForm.php
@@ -67,34 +67,37 @@ class LinkCheckerEditLinkSettingsForm {
   public function submitForm(array &$form, FormStateInterface $form_state) {
     // Force link re-check asap.
     if ($form_state->getValue('recheck')) {
-      db_update('linkchecker_link')
+      //db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array('last_checked' => 0))
+        ->fields(['last_checked' => 0])
         ->execute();
       drupal_set_message(t('The link %url will be checked again on the next cron run.', ['%url' => $form_state->getValue('url')]));
     }
 
     if ($form_state->getValue('method') != $form['settings']['method']['#default_value']) {
       // Update settings and reset statistics for a quick re-check.
-      db_update('linkchecker_link')
+     // db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'fail_count' => 0,
           'last_checked' => 0,
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
       drupal_set_message(t('The link settings for %url have been saved and the fail counter has been reset.', array('%url' => $form_state->getValue('url'))));
     }
     else {
       // Update setting only.
-      db_update('linkchecker_link')
+      //db_update('linkchecker_link')
+      \Drupal::database()->update('linkchecker_link')
         ->condition('lid', $form_state->getValue('lid'))
-        ->fields(array(
+        ->fields([
           'method' => $form_state->getValue('method'),
           'status' => $form_state->getValue('status'),
-        ))
+        ])
         ->execute();
       drupal_set_message(t('The link settings for %url have been saved.', array('%url' => $form_state->getValue('url'))));
     }
@@ -110,6 +113,7 @@ class LinkCheckerEditLinkSettingsForm {
   public function access($link) {
     // Check permissions and combine that with any custom access checking needed. Pass forward
     // parameters from the route and/or request as needed.
+    $account = \Drupal::currentUser();
     return AccessResult::allowedIf($account->hasPermission('edit link settings') && _linkchecker_link_access($link));
         //$this->someOtherCustomCondition());
   }
