Some database functions (db_or(), db_condition(), db_like() and db_select()) which we use in the database backend have recently been marked as deprecated. These should be substituted with their OOP equivalents or method calls through $this->database (in the case of db_select() – the current code is even wrong, in that aspect, not just deprecated).

Issue fork search_api-2547749

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

drunken monkey created an issue. See original summary.

joshi.rohit100’s picture

Assigned: Unassigned » joshi.rohit100
joshi.rohit100’s picture

Assigned: joshi.rohit100 » Unassigned
grahl’s picture

Status: Active » Needs review
StatusFileSize
new4.16 KB

Attached is a straight copy & paste from the deprecated functions for the new calls. I did not directly verify all.

Status: Needs review » Needs work

The last submitted patch, 4: 2547749-Remove-deprecated-calls.patch, failed testing.

HeimdallJHM’s picture

+++ b/src/Plugin/views/filter/SearchApiTerm.php
@@ -303,7 +303,8 @@ class SearchApiTerm extends SearchApiFilterEntityBase {
   protected function idsToString(array $ids) {
-    return implode(', ', db_select('taxonomy_term_data', 'td')
+
+    return implode(', ', Database::getConnection()->select('taxonomy_term_data', 'td')

why the new blank line?

drunken monkey’s picture

Thanks for the patch!

  1. +++ b/search_api_db/src/Plugin/search_api/backend/Database.php
    @@ -1718,7 +1718,7 @@ class Database extends BackendPluginBase {
    +        $or = new Condition('OR');
    

    This leads to a fatal error because you don't import the Condition class.

  2. +++ b/search_api_db/src/Plugin/search_api/backend/Database.php
    @@ -1782,7 +1782,7 @@ class Database extends BackendPluginBase {
    +          $cond->condition($alias . '.item_id', Database::getConnection()->escapeLike($prefix) . '%', $operator);
    

    In the Database backend class, we should not use Database::getConnection() but our own $database property.

And yes, please also delete the new blank line.

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new4.11 KB
new1.53 KB

Status: Needs review » Needs work

The last submitted patch, 8: 2547749-8.patch, failed testing.

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new4.1 KB
new593 bytes

Status: Needs review » Needs work

The last submitted patch, 10: 2547749-10.patch, failed testing.

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new4.09 KB
new629 bytes

Hope this is last :)

joshi.rohit100’s picture

Finally green **sigh**

drunken monkey’s picture

StatusFileSize
new9.73 KB
new5.64 KB

Thanks, looks great!

However, a quick search revealed a few more places where those functions were used. See the attached patch.
If the test bot is happy, though, I can commit this version then.
In any case, thanks again for your work!

Status: Needs review » Needs work

The last submitted patch, 14: 2547749-14--deprecated_db_functions.patch, failed testing.

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new10.96 KB
new1.14 KB

I tried to debug the failed testcase and it seems that field-name-title is replace by field--name-title, so I just did that.

Hope its not wrong.

drunken monkey’s picture

Hope its not wrong.

Ah, didn't see your comment, sorry. Since this failed for all patches, not just in this issue, I just fixed it in a separate issue (#2559303: Adapt RenderedItemTest to latest Core node template change). But the fix was correct, thanks.

drunken monkey’s picture

Status: Needs review » Fixed

OK, seems to be good to go. (The CI test fails because it used the module version from the time the patch was posted – idiotic, in my opinion, but it seems to have made sense to someone.)
Committed.
Thanks again for your work!

Status: Fixed » Closed (fixed)

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

gabesullice made their first commit to this issue’s fork.