Since most of the db_* methods to access database have been deprecated , all calls to such methods should be replaced with new syntax to access database. Check the following for more details.https://api.drupal.org/api/drupal/core%21includes%21database.inc/functio... . There is already an issue created for Drupal core https://www.drupal.org/node/2848161 to replace all calls to such methods.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dhruveshdtripathi created an issue. See original summary.

Pavan B S’s picture

Pavan B S’s picture

Assigned: Pavan B S » Unassigned
joelpittet’s picture

Version: 8.x-1.0-alpha4 » 8.x-1.x-dev
Priority: Major » Normal
Status: Needs review » Reviewed & tested by the community

Major would be a "must", this is a "should" so changing it to normal. Also the patch will need to apply against 1.x-dev so changing the version. Otherwise looks good.

Berdir’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/redirect.generate.inc
    @@ -140,10 +139,11 @@ function redirect_generate_batch_generate($num, array &$context) {
    -          'count' => mt_rand(1, 500),
    -          'access' => mt_rand(REQUEST_TIME - 31536000, REQUEST_TIME),
    +    $query = \Drupal::database();
    +    $query->update('redirect')
    +          ->fields(array(
    

    same here, this is also off, in the other direction.

  2. +++ b/redirect.install
    @@ -38,7 +38,8 @@ function redirect_update_8100(&$sandbox) {
         if ($row->hash != $new_hash) {
           // Do a direct query to speed things up.
    -      db_update('redirect')
    +        $query = \Drupal::database();
    +        $query->update('redirect')
    

    indendation is incorrect here. also no reason to make two lines out of this.

dhruveshdtripathi’s picture

Assigned: Unassigned » dhruveshdtripathi

Working on it

dhruveshdtripathi’s picture

Assigned: dhruveshdtripathi » Unassigned
Status: Needs work » Needs review
FileSize
3.42 KB
1.39 KB

Changes made according to comment #5. Interdiff added

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Indentation fixed, back to RTBC

Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

New syntax gives database exception in case with sqllite? Getting fatal mysql errors while trying to save a redirect to different URL