After installing the Extended Path Aliases module, I noticed that some of my url redirects stop working.

The reason being is because my redirect contained part of a taxonomy name e.g. /workplace/business, which resulting in 'no term' screen instead of redirecting to the relevant screen.

In order to fix this I increased the Extended Path Aliases module weight so it was called after the redirect module. Does this module need to be weighted before all of the other modules i.e. -1 and if so is there anyway round this?

Thanks,

Richard

Comments

rdeboer’s picture

Assigned: rviner » rdeboer

Hi Richard,
The weight was changed to -1 because of similar problems when Extended Path Aliases is used with other modules.
Sounds like we have a catch 22....
To work with the Redirect module the weight of Extended Path Aliases needs to be greater than 0, for some other modules it needs to be less than 0....
Not sure what to do other than to comment it in the README?
Rik

rviner’s picture

Hi Rik,

Ok thanks for the info. I don't see this as being a big problem so I'll take it by a case by case basis. I can't see that much can be done so a note in the README would be handy.

Richard

marcoka’s picture

the module weight has to be changed in the database right?

rdeboer’s picture

Yes. The {system} table has a weight column. You need to change the value of the weight column for the row/cell corresponding to the module name.

dagomar’s picture

For me changing the weight didn't change the faulty behaviour. So I came up with this in the function path_alias_xt_url_inbound_alter:

if ($menu_item_path = _path_alias_xt_get_menu_item($candidate_alias)) {
        return;
      }
      if(module_exists('redirect')) {
        $redirect = db_query("SELECT source FROM {redirect} WHERE source = :source", array(':source' => $candidate_alias))->fetchField();
        if ($redirect) {
          return;
        }
      }

May not be the best solution, but it works for me. Should I make a patch? It took me almost a whole day to debug this!

dagomar’s picture

Status: Active » Needs review
StatusFileSize
new819 bytes

I decided to create a patch regardless. I'll leave it here in case someone needs it.

ivanstegic’s picture

StatusFileSize
new1.47 KB

We've been struggling with this on a very high traffic site, and were able to get it to work appropriately by changing the weight. However, I actually agree with #5 and think this is a better way to solve the problem, since the weight should really be -1 as intended.

This patch goes a little further -- given that we are also affected by #1796596: Fix and prevent circular redirects and that patch makes a schema change to Redirect itself, I've added some schema version checking of Redirect. The ability to designate a redirect as active or not should be taken into account for schema versions starting with 7101.

It would be great to see the RTBC and into the module soon!

franz’s picture

+++ b/path_alias_xt.module
@@ -106,6 +106,24 @@ function path_alias_xt_url_inbound_alter(&$path, $original_path, $path_language)
+      if(module_exists('redirect')) {

Quick note: should have a space after 'if'

bember’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
StatusFileSize
new1.39 KB

Adding a patch that combines #6 and #7.

franz’s picture

Status: Needs review » Reviewed & tested by the community

Patch works fine.

bember’s picture

StatusFileSize
new1.38 KB

Best practices fix: moving code block to a better place.

El Bandito’s picture

I'm seeing an issue where a redirect from the path :

top/middle/tail ( which is node number 111111 )

is getting re-written to :

node/222222/tail

where node/222222 is the nid of of the node aliased as 'top/middle'.

The patch fixes existing redirects but when a new redirect to node/1111111 is created it receives the destination node/222222/tail which causes the browser to display node/222222.

mikhailkrainiuk’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Assigned: rdeboer » Unassigned
Status: Reviewed & tested by the community » Needs work

Hello,

We have the same conflict with Redirect module for Drupal 8.

What if we will check the new path to exist?
For example:
- "top/middle/tail" will be redirected after current module
- we have "node/222" with the alias "top/middle"

New logic:
- the module generates a new candidate "node/222/tail"
- we check the path "node/222/tail" to exist
It does not exist. We don't change the path.

If we have "top/middle/edit", it will be changed to "node/222/edit" that exists. The module returns "node/222/edit".

mikhailkrainiuk’s picture

Issue tags: +Needs backport to D7
kala4ek’s picture

Assigned: Unassigned » kala4ek
Status: Needs work » Needs review
StatusFileSize
new2.97 KB
kala4ek’s picture

Assigned: kala4ek » Unassigned
StatusFileSize
new2.97 KB

Here is patch for D8.

iancawthorne’s picture

Just wanted to add that I was getting the following error on all node instances (node/x, node/x/edit, node/x/anything etc both aliased and non aliased) when creating a view with a contextual filter of node id in this format "node/%/something", with extended path alias and also redirect module enabled.

The error in the watchdog is:
Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("arg_0") to generate a URL for route "view.view_name.page_1". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 180 of /pathtosite/core/lib/Drupal/Core/Routing/UrlGenerator.php).

Applying the patch at #16 has resolved this problem.

Looking back at this thread, I'm not sure it describes the same issue as I was having, but has certainly also resolved it, possibly indirectly.

nwom’s picture

Status: Needs review » Reviewed & tested by the community

#16 works great and applied cleanly. Thank you!

  • adriancid committed 80a4ccc on 8.x-1.x authored by kala4ek
    Issue #2220339 by kala4ek, bember, dagomar, ivanstegic, rviner, franz,...
adriancid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for this

adriancid’s picture

Status: Fixed » Closed (fixed)

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