commit eee37aaa3df3e476048b2200596c0da25161154f
Author: rsathishkumar <sathish2006cbe@gmail.com>
Date:   Thu Apr 27 16:58:15 2017 +0530

    replaced deprecated functions

diff --git a/modules/xmlsitemap/src/Tests/XmlSitemapNodeFunctionalTest.php b/modules/xmlsitemap/src/Tests/XmlSitemapNodeFunctionalTest.php
index 9eb0701..24352c7 100644
--- a/modules/xmlsitemap/src/Tests/XmlSitemapNodeFunctionalTest.php
+++ b/modules/xmlsitemap/src/Tests/XmlSitemapNodeFunctionalTest.php
@@ -209,7 +209,7 @@ public function testCron() {
     }
 
     // Clear all the node link data so we can emulate 'old' nodes.
-    db_delete('xmlsitemap')
+    \Drupal::database()->delete('xmlsitemap')
         ->condition('type', 'node')
         ->execute();
 
diff --git a/modules/xmlsitemap/src/Tests/XmlSitemapTestBase.php b/modules/xmlsitemap/src/Tests/XmlSitemapTestBase.php
index 91dc9cf..3f6edce 100644
--- a/modules/xmlsitemap/src/Tests/XmlSitemapTestBase.php
+++ b/modules/xmlsitemap/src/Tests/XmlSitemapTestBase.php
@@ -320,7 +320,7 @@ protected function getWatchdogMessages(array $conditions = array(), $reset = FAL
       return array();
     }
 
-    $query = db_select('watchdog');
+    $query = \Drupal::database()->select('watchdog');
     $query->fields('watchdog', array('wid', 'type', 'severity', 'message', 'variables', 'timestamp'));
     foreach ($conditions as $field => $value) {
       if ($field == 'variables' && !is_string($value)) {
diff --git a/modules/xmlsitemap/src/Tests/XmlSitemapUnitTest.php b/modules/xmlsitemap/src/Tests/XmlSitemapUnitTest.php
index acb104a..40a8c09 100644
--- a/modules/xmlsitemap/src/Tests/XmlSitemapUnitTest.php
+++ b/modules/xmlsitemap/src/Tests/XmlSitemapUnitTest.php
@@ -74,12 +74,12 @@ public function testGetChunkCount() {
     $this->config->set('chunk_size', 4)->save();
 
     // Make the total number of links just equal to the chunk size.
-    $count = db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField();
+    $count = \Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField();
     for ($i = $count; $i < 4; $i++) {
       $this->addSitemapLink();
       $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1);
     }
-    $this->assertEqual(db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 4);
+    $this->assertEqual(\Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 4);
 
     // Add a disabled link, should not change the chunk count.
     $this->addSitemapLink(array('status' => FALSE));
@@ -90,13 +90,13 @@ public function testGetChunkCount() {
     $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 2);
 
     // Change all links to disabled. The chunk count should be 1 not 0.
-    db_query("UPDATE {xmlsitemap} SET status = 0");
+    \Drupal::database()->query("UPDATE {xmlsitemap} SET status = 0");
     $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1);
     $this->assertEqual(xmlsitemap_get_link_count(), 0);
 
     // Delete all links. The chunk count should be 1 not 0.
-    db_query("DELETE FROM {xmlsitemap}");
-    $this->assertEqual(db_query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 0);
+    \Drupal::database()->query("DELETE FROM {xmlsitemap}");
+    $this->assertEqual(\Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap}")->fetchField(), 0);
     $this->assertEqual(xmlsitemap_get_chunk_count(TRUE), 1);
   }
 
diff --git a/modules/xmlsitemap/src/XmlSitemapGenerator.php b/modules/xmlsitemap/src/XmlSitemapGenerator.php
index e0805dd..c265725 100644
--- a/modules/xmlsitemap/src/XmlSitemapGenerator.php
+++ b/modules/xmlsitemap/src/XmlSitemapGenerator.php
@@ -88,7 +88,7 @@ public function __construct(ConfigFactoryInterface $config_factory, StateInterfa
    * {@inheritdoc}
    */
   public function getPathAlias($path, $language) {
-    $query = db_select('url_alias', 'u');
+    $query = \Drupal::database()->select('url_alias', 'u');
     $query->fields('u', array('source', 'alias'));
     if (!isset(static::$aliases)) {
       $query->condition('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED, '=');
@@ -152,7 +152,7 @@ public function getOptimalMemoryLimit() {
 
       // Add memory for storing the url aliases.
       if ($this->config->get('prefetch_aliases')) {
-        $aliases = db_query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
+        $aliases = \Drupal::database()->query("SELECT COUNT(pid) FROM {url_alias}")->fetchField();
         $optimal_limit += $aliases * 250;
       }
     }
@@ -209,7 +209,7 @@ public function generateChunk(XmlSitemapInterface $sitemap, XmlSitemapWriter $wr
     $last_url = '';
     $link_count = 0;
 
-    $query = db_select('xmlsitemap', 'x');
+    $query = \Drupal::database()->select('xmlsitemap', 'x');
     $query->fields('x', array('loc', 'lastmod', 'changefreq', 'changecount', 'priority', 'language', 'access', 'status'));
     $query->condition('x.access', 1);
     $query->condition('x.status', 1);
@@ -371,7 +371,7 @@ public function regenerateBatchFinished($success, $results, $operations, $elapse
    */
   public function rebuildBatchClear(array $entity_type_ids, $save_custom, &$context) {
     if (!empty($entity_type_ids)) {
-      $query = db_delete('xmlsitemap');
+      $query = \Drupal::database()->delete('xmlsitemap');
       $query->condition('type', $entity_type_ids, 'IN');
 
       // If we want to save the custom data, make sure to exclude any links
diff --git a/modules/xmlsitemap/src/XmlSitemapLinkStorage.php b/modules/xmlsitemap/src/XmlSitemapLinkStorage.php
index db448de..57e9792 100644
--- a/modules/xmlsitemap/src/XmlSitemapLinkStorage.php
+++ b/modules/xmlsitemap/src/XmlSitemapLinkStorage.php
@@ -194,7 +194,7 @@ public function checkChangedLinks(array $conditions = array(), array $updates =
     $conditions['status'] = (!empty($updates['status']) && empty($conditions['status'])) ? 0 : 1;
     $conditions['access'] = (!empty($updates['access']) && empty($conditions['access'])) ? 0 : 1;
 
-    $query = db_select('xmlsitemap');
+    $query = \Drupal::database()->select('xmlsitemap');
     $query->addExpression('1');
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
@@ -226,7 +226,7 @@ public function deleteMultiple(array $conditions) {
     }
 
     // @todo Add a hook_xmlsitemap_link_delete() hook invoked here.
-    $query = db_delete('xmlsitemap');
+    $query = \Drupal::database()->delete('xmlsitemap');
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
     }
@@ -245,7 +245,7 @@ public function updateMultiple($updates = array(), $conditions = array(), $check
     }
 
     // Process updates.
-    $query = db_update('xmlsitemap');
+    $query = \Drupal::database()->update('xmlsitemap');
     $query->fields($updates);
     foreach ($conditions as $field => $value) {
       $query->condition($field, $value);
@@ -266,7 +266,7 @@ public function load($entity_type, $entity_id) {
    * {@inheritdoc}
    */
   public function loadMultiple(array $conditions = array()) {
-    $query = db_select('xmlsitemap');
+    $query = \Drupal::database()->select('xmlsitemap');
     $query->fields('xmlsitemap');
 
     foreach ($conditions as $field => $value) {
diff --git a/modules/xmlsitemap/xmlsitemap.api.php b/modules/xmlsitemap/xmlsitemap.api.php
index f642527..a5d4704 100644
--- a/modules/xmlsitemap/xmlsitemap.api.php
+++ b/modules/xmlsitemap/xmlsitemap.api.php
@@ -80,7 +80,7 @@ function hook_xmlsitemap_link_alter(&$link) {
  * @see hook_xmlsitemap_link_update()
  */
 function hook_xmlsitemap_link_insert(array $link) {
-  db_insert('mytable')
+  \Drupal::database()->insert('mytable')
       ->fields(array(
         'link_type' => $link['type'],
         'link_id' => $link['id'],
@@ -99,7 +99,7 @@ function hook_xmlsitemap_link_insert(array $link) {
  * @see hook_xmlsitemap_link_insert()
  */
 function hook_xmlsitemap_link_update(array $link) {
-  db_update('mytable')
+  \Drupal::database()->update('mytable')
       ->fields(array(
         'link_type' => $link['type'],
         'link_id' => $link['id'],
@@ -217,7 +217,7 @@ function hook_xmlsitemap_sitemap_operations() {
  *   The XML sitemap object that was deleted.
  */
 function hook_xmlsitemap_sitemap_delete(XmlSitemapInterface $sitemap) {
-  db_query("DELETE FROM {mytable} WHERE smid = '%s'", $sitemap->smid);
+  \Drupal::database()->query("DELETE FROM {mytable} WHERE smid = '%s'", $sitemap->smid);
 }
 
 /**
diff --git a/modules/xmlsitemap/xmlsitemap.drush.inc b/modules/xmlsitemap/xmlsitemap.drush.inc
index 4f2fba2..eaa3aaa 100644
--- a/modules/xmlsitemap/xmlsitemap.drush.inc
+++ b/modules/xmlsitemap/xmlsitemap.drush.inc
@@ -76,11 +76,11 @@ function drush_xmlsitemap_rebuild() {
  */
 function drush_xmlsitemap_index() {
   $limit = (int) drush_get_option('limit', \Drupal::config('xmlsitemap.settings')->get('batch_limit'));
-  $count_before = db_select('xmlsitemap', 'x')->countQuery()->execute()->fetchField();
+  $count_before = \Drupal::database()->select('xmlsitemap', 'x')->countQuery()->execute()->fetchField();
 
   \Drupal::moduleHandler()->invokeAll('xmlsitemap_index_links', array('limit' => $limit));
 
-  $count_after = db_select('xmlsitemap', 'x')->countQuery()->execute()->fetchField();
+  $count_after = \Drupal::database()->select('xmlsitemap', 'x')->countQuery()->execute()->fetchField();
 
   if ($count_after == $count_before) {
     drush_print(dt('No new XML sitemap links to index.'));
diff --git a/modules/xmlsitemap/xmlsitemap.module b/modules/xmlsitemap/xmlsitemap.module
index 6f031be..3ed3ac8 100644
--- a/modules/xmlsitemap/xmlsitemap.module
+++ b/modules/xmlsitemap/xmlsitemap.module
@@ -716,8 +716,8 @@ function xmlsitemap_get_link_type_indexed_status($entity_type_id, $bundle = '')
   $info = xmlsitemap_get_link_info($entity_type_id);
   $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
 
-  $status['indexed'] = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle", array(':entity' => $entity_type_id, ':bundle' => $bundle))->fetchField();
-  $status['visible'] = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle AND status = 1 AND access = 1", array(':entity' => $entity_type_id, ':bundle' => $bundle))->fetchField();
+  $status['indexed'] = \Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle", array(':entity' => $entity_type_id, ':bundle' => $bundle))->fetchField();
+  $status['visible'] = \Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle AND status = 1 AND access = 1", array(':entity' => $entity_type_id, ':bundle' => $bundle))->fetchField();
 
   try {
     $query = \Drupal::entityQuery($entity_type_id);
@@ -1008,7 +1008,7 @@ function xmlsitemap_get_chunk_count($reset = FALSE) {
 function xmlsitemap_get_link_count($reset = FALSE) {
   static $count;
   if (!isset($count) || $reset) {
-    $count = db_query("SELECT COUNT(id) FROM {xmlsitemap} WHERE access = 1 AND status = 1")->fetchField();
+    $count = \Drupal::database()->query("SELECT COUNT(id) FROM {xmlsitemap} WHERE access = 1 AND status = 1")->fetchField();
   }
   return $count;
 }
diff --git a/modules/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php b/modules/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php
index 7d5fc97..42c8cf0 100644
--- a/modules/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php
+++ b/modules/xmlsitemap/xmlsitemap_custom/src/Controller/XmlSitemapCustomListController.php
@@ -33,7 +33,7 @@ public function render() {
 
     $rows = array();
 
-    $query = db_select('xmlsitemap');
+    $query = \Drupal::database()->select('xmlsitemap');
     $query->fields('xmlsitemap');
     $query->condition('type', 'custom');
     $query->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(50);
