Problem/Motivation

Due to the need of proposing actors in text mentions from following/followers while writing, it will be great to add like queries in a way that lets use for example %/alis% or "https://{$domain}%/{$username}%" . Now is not possible because LIKE conditions in storage query are just available if used with the "search" field.

Proposed resolution

As similar to how conditions are processed in ActivityPubActivityStorage.php:getBaseQuery for example in the case of < operator : (strpos($field, '<') !== FALSE), we could allow LIKE conditionals with :

if (strpos($field, 'LIKE') !== FALSE) {                                                                                                                          
 $operator = 'LIKE';                                                                                                                                            
 $field = str_replace('LIKE', '', $field);                                                                                                                      
}
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

aleix created an issue. See original summary.

aleix’s picture

Issue summary: View changes
Status: Active » Needs review
swentel’s picture

Hmm, I wonder if we also should escape the query as done in the 'search' part in baseQuery, or is it good enough for your use case?

swentel’s picture

Maybe the escape isn't that necessary, but maybe wildcards are?

aleix’s picture

I tried to escape and it will escape the wildcards... because we need to look for:

https://{$domain}%/{$username}%

Also, when wildcards are there we end up with something like "%https://{$domain}%/{$username}%", leading to something different to what it is looked for.

swentel’s picture

right, makes sense. I guess we can use str_contains instead of the strpos call (and replace the rest as well)

  • swentel committed ea40f24e on 1.0.x authored by aleix
    Issue #3520021: Allow like conditions in activities storage query
    
swentel’s picture

Status: Needs review » Fixed

Merged in, thanks!

Status: Fixed » Closed (fixed)

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