I have the need to alter the db_select query within redirect_load_by_source() dynamically. Per https://drupal.org/node/310077, I need to tag the db_select so it is alterable.

Only queries that have been tagged by the original creator can be altered later. Most of Drupals everyday small queries are not explicitly tagged and therefore not alterable in this way.

Comments

heddn’s picture

StatusFileSize
new854 bytes

Here's a super simple alter patch. What this lets me do is insert my own custom $_SERVER['HTTP_HOST'] logic. I extend the redirect schema to add a hostname column, altered the edit form to allow a hostname field and now I have a working solution to handle redirect on hostname, in addition to simply the URL path.

heddn’s picture

Status: Active » Needs review
heddn’s picture

To be completely clear, the logic in #1 is all added in a custom module.

pere orga’s picture

And what about having a more specific name (for example redirect_load)?

I imagine more tags could be added in the future.

pere orga’s picture

Status: Needs review » Reviewed & tested by the community

Ok, after reading https://www.drupal.org/node/310077 I see that having a 'redirect' tag woud be acceptable, as what is saying is that the query was created by Redirect module. More tags could always be added.

Patch applies and works, thanks

Edit: Still, I think adding another tag may be useful

dave reid’s picture

We already use the 'redirect_access' tag, could it not be re-used here?

berdir’s picture

@Dave Reid: Using the access tag would also hide redirects from different domains on the overview, I don't think that is desired.

Based on that, a more specific tag like redirect_load_by_source or so might be a good idea, especially as others like redirect_list and redirect_access already exist.

dave reid’s picture

Status: Reviewed & tested by the community » Needs work

Needs work to use a more specific tag name.

The last submitted patch, 1: 2211279-redirect_alter-db-select.patch, failed testing.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new577 bytes

I'm picking this up again for some client work related to https://www.drupal.org/sandbox/lucashedding/2242839. More specific tag added.

ankurj’s picture

Status: Needs review » Reviewed & tested by the community

That patch from @heddn in #11 looks good.

pifagor’s picture

RTBC

alex_optim’s picture

Looks good too.

pifagor’s picture

  • pifagor committed 20313f3 on 7.x-2.x authored by heddn
    Issue #2211279 by heddn, Dave Reid, pifagor, Pere Orga, Berdir, ankurj,...

  • pifagor committed 5887750 on 7.x-1.x
    Issue #2211279 by heddn, Dave Reid, pifagor, Pere Orga, Berdir, ankurj,...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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