In drupal 8 we should not use the depreciated db_queries.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Munavijayalakshmi created an issue. See original summary.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Active » Needs review
FileSize
3.23 KB
borisson_’s picture

Title: Removed depreciated Database queries. » Removed deprecated Database queries.
Status: Needs review » Needs work

Please use proper DI to do this instead. This does remove the deprecated function calls but replaces them with the same problem.

  1. +++ b/modules/core_search_facets/src/Plugin/facets/facet_source/CoreNodeSearchFacetSource.php
    @@ -261,7 +261,7 @@ class CoreNodeSearchFacetSource extends FacetSourcePluginBase implements CoreSea
    -      $this->facetQueryExtender = db_select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\core_search_facets\FacetsQuery');
    +      $this->facetQueryExtender = \Drupal::database()->select('search_index', 'i', array('target' => 'replica'))->extend('Drupal\core_search_facets\FacetsQuery');
    

    Let's make sure that this code flows closer to 80 cols, we're touching it here so seems like a good time to do that.

  2. +++ b/src/Plugin/facets/hierarchy/Taxonomy.php
    @@ -34,7 +34,7 @@ class Taxonomy extends HierarchyPluginBase {
           // TODO: refactor to swap out deprecated db_select.
    -      $query = db_select('taxonomy_term_hierarchy', 'h');
    +      $query = \Drupal::database()->select('taxonomy_term_hierarchy', 'h');
    

    Remove @todo

  3. +++ b/src/Plugin/facets/hierarchy/Taxonomy.php
    @@ -53,7 +53,7 @@ class Taxonomy extends HierarchyPluginBase {
         // TODO: refactor to swap out deprecated db_select.
    ...
    -    $result = db_select('taxonomy_term_hierarchy', 'th')
    +    $result = \Drupal::database()->select('taxonomy_term_hierarchy', 'th')
    

    Remove @todo

borisson_’s picture

Issue tags: +Novice

Tagging as Novice.

scottcwilson’s picture

I'd like to try working on this one.

arunkumark’s picture

Status: Needs work » Needs review
FileSize
3.32 KB

I have re-rolled the patch.

borisson_’s picture

Status: Needs review » Needs work

Dependency injection is not used yet for these. Back to needs work.

jzavrl’s picture

Status: Needs work » Needs review
FileSize
10.29 KB
8.74 KB

Rerolled the patch to make use of dependency injection. Have also removed the deprecated db_or() calls from the files and fixed some coding standards warnings.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Looks good! Thanks for those changes!

borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

  • borisson_ committed 75561ce on 8.x-1.x authored by jzavrl
    Issue #2880344 by jzavrl, Munavijayalakshmi, arunkumark, borisson_:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.