Problem
Currently the language for a redirect applies to both, source (From) and redirect (To). If you want to redirect to a german page let's say - then the actual redirect source needs to be a german path as well. When you want to use redirect module to redirect legacy paths to new drupal paths, this is a blocker.
Example
An example: You want to redirect "the-old-german-path.html" to the "de/new-fancy-drupal-path" (alias for node/123 in language German). If you try to use the old path as a "From" source, the new path as "To", and choose German as a language, then the redirect is only triggerd on 'de/the-old-german-path.html' - as the language you have chosen for the redirect is German.
Proposed Solution
As a proposed solution, I added a new setting to each redirect, called "Language neutral source". If this checkbox is set, then the redirect is triggered without language prefix. The language in the prefix is still used for the target (To) path.
Before: de/the-old-german-path.html redirects to de/new-fancy-drupal-path
After: the-old-german-path.html redirects to de/new-fancy-drupal-path
A patch follows...
| Comment | File | Size | Author |
|---|---|---|---|
| #64 | 1983444-64.patch | 9 KB | kapilv |
| #63 | 1983444-63.patch | 8.08 KB | kapilv |
| #48 | interdiff-19834444-47-48.txt | 1.42 KB | zrpnr |
| #48 | redirect-language-neutral-source-1983444-48.patch | 8.1 KB | zrpnr |
Comments
Comment #1
valderama commentedComment #2
mxtAfter applying your patch I can't access my site any more, receiving the following error:
Can you please reroll your patch againist LATEST dev version of redirect module?
I really need to try this patch to resolve the issue you described (and also described here: https://drupal.org/node/1682288 )
Thank you very much
MXT
Comment #3
mxtAfter manually create the missing column in redirect table, my sites restarts to working.
I've checked the "From" is language neutral new option in my node, but the main issue is not resolved, receiving the following error:
Comment #4
mxtThe above error is triggered only if you choose "all languages" in redirect settings in node admin page.
Instead, if you select a specific language, the error disappears and your patch WORKS GREAT!!!
Thank you very much!
Comment #5
mxtThe error triggered using "all languages" have to be managed, and upgrade path should create itself the new column in redirect table.
Comment #6
Vincenzo commentedI am working on this one.
Comment #7
Vincenzo commentedA new version of the originally proposed patch.
It includes an upgrade path now and some minor stuff.
I couldn't reproduce the other issue that MXT was mentioning about "All languages".
Please test this one.
Comment #9
brightboldUsing the patch in #7, I am having the same problem as MXT with the PDO error. It seems like an error you would get if you had failed to run update.php, but I did that and I cleared the cache. I, too, first attempted to create an 'All Languages' redirect (before I remembered to run update.php, oops).
Comment #10
brightboldOK I can't figure this out. There is a column language_neutral_source in the redirect table, so I don't know why I'm getting this error or what I can do to prevent it. For now I'll have to roll back this patch and live without un-prefixed redirects.
Comment #11
erichomanchuk commentedThe field name in the update hook was misspelled so when you ran the update you would get an error about a missing field when visiting the redirect config page. I changed the update hook to add the correct field to the redirect table.
Remember to run update.php or drush updb and then clear caches.
Comment #13
antondavidsen commentedFixed the warning described in #3
Comment #14
webadpro commentedIs there a way to test the latest patch?
Comment #15
knalstaaf commentedBoth #13 and #11 aren't working for me (ran update.php / cleared cache).
The situation is so that I have to redirect paths that are not existing on the current installation. They're from a previous (Wordpress) installation (which didn't have a language prefix in the default language).
This module looked very much like what I needed to redirect old links in the search engine's results to the proper new pages. Maybe I should ask...
Comment #16
valderama commentedLets see what the testbot says...
Comment #17
valderama commentedYay, testbot is fine with the patch!
I just tested it manually and it is working as expected, so I'll put it as reviewed and tested by the community.
Comment #18
knalstaaf commentedI'm getting this error visiting the redirect config page after applying patch #13 on Redirect 7.x-1.0-rc1+8-dev (2014-Jul-23):
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.language_neutral_source' in 'field list': SELECT base.rid AS rid, base.hash AS hash, base.type AS type, base.uid AS uid, base.source AS source, base.source_options AS source_options, base.redirect AS redirect, base.redirect_options AS redirect_options, base.language AS language, base.status_code AS status_code, base.count AS count, base.access AS access, base.language_neutral_source AS language_neutral_source FROM {redirect} base WHERE (base.rid IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5, :db_condition_placeholder_6, :db_condition_placeholder_7, :db_condition_placeholder_8, :db_condition_placeholder_9, :db_condition_placeholder_10, :db_condition_placeholder_11, :db_condition_placeholder_12, :db_condition_placeholder_13, :db_condition_placeholder_14, :db_condition_placeholder_15, :db_condition_placeholder_16, :db_condition_placeholder_17, :db_condition_placeholder_18, :db_condition_placeholder_19, :db_condition_placeholder_20, :db_condition_placeholder_21, :db_condition_placeholder_22, :db_condition_placeholder_23, :db_condition_placeholder_24, :db_condition_placeholder_25, :db_condition_placeholder_26)) ; Array ( [:db_condition_placeholder_0] => 23 [:db_condition_placeholder_1] => 18 [:db_condition_placeholder_2] => 20 [:db_condition_placeholder_3] => 2 [:db_condition_placeholder_4] => 21 [:db_condition_placeholder_5] => 22 [:db_condition_placeholder_6] => 24 [:db_condition_placeholder_7] => 19 [:db_condition_placeholder_8] => 17 [:db_condition_placeholder_9] => 16 [:db_condition_placeholder_10] => 15 [:db_condition_placeholder_11] => 9 [:db_condition_placeholder_12] => 12 [:db_condition_placeholder_13] => 14 [:db_condition_placeholder_14] => 1 [:db_condition_placeholder_15] => 7 [:db_condition_placeholder_16] => 8 [:db_condition_placeholder_17] => 11 [:db_condition_placeholder_18] => 13 [:db_condition_placeholder_19] => 10 [:db_condition_placeholder_20] => 6 [:db_condition_placeholder_21] => 5 [:db_condition_placeholder_22] => 26 [:db_condition_placeholder_23] => 28 [:db_condition_placeholder_24] => 27 [:db_condition_placeholder_25] => 3 [:db_condition_placeholder_26] => 4 ) in DrupalDefaultEntityController->load() (line 191 van /home/domain/public_html/includes/entity.inc).It's also impossible to empty the Drupal cache (I'm getting a 404).
Comment #19
tommeir commentedThank you for that patch! you saved my client's site url migration :)
knalstaaf - it works but you need to execute update.php to let it install the new table column.
Comment #20
valderama commentedI manually re-examined and re-tested the current patch. The changes still makes sense to me and I would be really glad to at least get feedback from the maintainer.
I have made minor changes: added a comment and re-named the hook_update_N function to apply to current dev.
@knalstaaf - Please re-try with this patch - I think your problem was that the update hook was not executed, due to an outdated naming of it.
Comment #21
valderama commentedSetting to "needs review" to trigger test bot.
Comment #22
valderama commentedComment #23
valderama commentedComment #24
TheBarnacle commented@knalstaaf did you ever get yours to work? I just added the #20 patch and am getting the same error as on #18.
Comment #25
TheBarnacle commentedNever mind - I hadn't run the db update. Now it works!
Comment #26
deanflory commentedThis patch fails when applied to the redirect module (dev) after this other issue's patch:
fix_and_prevent-1796596-249.patch
#1796596: Fix and prevent circular redirects
Results of this issue's patch run after applying the noted other issue's patch:
This patch did not fix my error. I'm now getting this when I try and go to my account page:
Comment #27
Michsk commentedSeems to work as expected for me.
Just as a side note i would recommed changing the label for the checkbox:
Source URL is language neutral
To something more close to the source field. So something like:
From URL is language neutral
That would make it easier for users who dont understand what that checkbox does.
Comment #28
Michsk commentedLatest patch does not work when page caching is enabled for anonymous users.
Comment #29
bohus ulrychHi all,
#20 seems to be working well on my installation (latest drupal + latest modules) even with caching module Boost.
Thank you
P.S. !! Do not forgot to update db after patching !!
Comment #30
mattew commentedI added two fixes to this patch, when the checkbox was checked:
Comment #31
Marko B commentedI worked here on similar thing https://www.drupal.org/node/2458325 slightly different approach.
Comment #32
mfernea commented#20 works for us too. We don't have Boost or page caching enabled.
Maybe for #30 it's best to have an interdiff too.
Comment #33
mattew commentedI think that adding a patch that rely on another one (#20) will not pass the tests. #30 contains all changes from #20, with some extra fixes, you can apply #30 instead of #20 without trouble.
Comment #34
mfernea commentedI would like to see the interdiff because it shows just the changes added by #30, so it's easier to review. It can't be used for anything else (afaik).
Comment #35
bessone commented#30 worked for me on last stable (7.x-1.0-rc1)
Comment #36
mattew commented@mfernea
As you already mentioned, a diff between two patch is useless, and as I said, I will not post such a patch as it will not pass the tests. So, DIY ! ;) http://www.quickdiff.com/
Comment #37
mfernea commentedCreating interdiffs is part of best practices when contributing.
https://www.drupal.org/documentation/git/interdiff
I will do it. :)
Comment #38
mfernea commentedHere is the interdiff between #30 and #20.
Comment #39
mattew commentedOK, my bad, I didn't know that I could supply an interdiff in .txt format.
Best regards
Comment #40
mattew commentedThis ticket is two years old... Please could you commit something?
The last RC2 implements a 7101 update hook to add a "status" field and could not work without it... so it is a big problem when we use this patch, which implements the same hook.
This patch is essential when you use this module to redirect URLs from an old non-drupal site to a multi-lingual one.
Comment #41
mfernea commentedHere is the patch from #30 rerolled onto 7.x-1.0-rc3.
I'm trying to figure out what's the best upgrade path for those that applied the patch while using 7.x-1.0-rc1 and now want to update the module.
Comment #42
mfernea commentedHere is the patch for 7.x-1.0-rc3 ONLY for those who applied either #20 or #30 patch while using 7.x-1.0-rc1 version.
Comment #43
mfernea commentedI should have suffixed the patch name from #42 with "do-not-test".
Comment #44
damienmckennaClosed a duplicate: #2486587: Problem with multilingual site
Comment #45
ckrinaPatch from #41 is working for me, in a clean install and in a production site. Thanks!
Maybe another tester would be better before moving to RTBC.
Comment #46
vijaycs85No need for placeholder here.
I don't think '===' works here as the form_state always send the form values as string.
Comment #47
zrpnrTested the patch in #41, seems to work very well, thanks!
Wondering why all source urls are not treated as language neutral by default? Seems like better behavior.
Marking this RTBC.
Regarding edits suggested by @vijaycs85 in #46, I don't think these are major blockers but I rerolled the patch with those changes to help get this work committed.
1. Placeholder using a string value was just emphasizing the text, replaced it.
2. When I debugged the 0 was not a string, it should work with either == or ===.
Made no other code changes, interdiff attached.
Comment #48
zrpnrIf this code is deployed, there are some database errors related to the new column.
Running update.php will fix- but it is better if the code doesn't break the site before updates are run.
Comment #49
joachim commented> If this code is deployed, there are some database errors related to the new column.
Running update.php will fix- but it is better if the code doesn't break the site before updates are run.
That is normal behaviour whenever a hook_update_n() makes database changes. Site builders are expected to put their site into maintenance before applying code updates, and only bring it back live once the updates have run.
Comment #50
joachim commentedPatch works great.
(Though anyone running this patch should be aware that there are at least TWO other issues for this project with RTBC patches which add redirect_update_7103(), so when these are eventually committed, your system updates will need some tinkering to work properly.)
Comment #51
joachim commentedI'm actually wondering now whether the 'language_neutral_source' option should be added to the 'source_options' serialized DB column, rather than its own column...
Is the source_options column just URL options though -- ie is the whole of that array passed to url() or similar?
Comment #52
dshields commentedI'm having issues with this patch.
When I try to run the updb via drush, I hit my php menory limit. While it eventually completes the update script in the browser, it certainly takes its time.
I'm wondering about joachim's comment about "system updates will need some tinkering to work properly" - could anyone expand on that? Should the update number be changed?
Comment #53
joachim commented> I'm wondering about joachim's comment about "system updates will need some tinkering to work properly" - could anyone expand on that? Should the update number be changed?
Yes, that's exactly it. Two other patches in the issue queue (at the time I wrote that comment) also try to add the same number update hook. Depending on what order the maintainer commits them, some will need to be renumbered. Furthermore, anyone applying one of these patches will need to fiddle with their system table to make sure all the updates are run.
Comment #54
dshields commentedAhh
Comment #55
misthero commentedpatch 48 works on 7.x-2.x-dev.
please commit :)
Comment #56
attiks commented#48 Works like a charm for 7.x-1.x
Comment #57
pifagorlook good
+1
Comment #58
bserem commentedThis needs to be patched on Drupal8 version of the module too, right?
Comment #59
pminfI think Allow Redirecting to another language is about this issue in Drupal 8.
Comment #60
pifagorPatch Failed to Apply
Comment #61
damienmckennaComment #62
q11q11 commentedPatch from #20 is ok for 7.x-1.0-rc1.
Patch from #48 is ok for 7.x-1.0-rc3.
While running updates from rc1 to rc3 (with patch from #48 applied to rc3) got this:
Comment #63
kapilv commentedHear a reroll patch.
Comment #64
kapilv commentedComment #65
kapilv commentedComment #66
wylbur commentedClosing this as Outdated as Drupal 7 is EOL.