drupal_get_normal_path() issue

Created on 7 December 2012, almost 12 years ago
Updated 18 April 2024, 5 months ago

I found this bug after I enabled Boost module. It tries to get system path using drupal_get_normal_path(). drupal_get_normal_path() doesn't return correct system path because we use slash at the end of our alias. I implemented hook_url_inbound_alter in Trailing Slash module and after that drupal_get_normal_path() works fine. I found this issue on taxonomy term pages only. All other pages work fine for me.

Steps to reproduce the issue:

  1. Create taxonomy term and set alias for it.
  2. Call drupal_get_normal_path() with trailing slash from some page.
  3. drupal_get_normal_path() won't return correct system path.

Here is my code which I added to Trailing Slash module:

/**
 * Implements hook_url_inbound_alter().
 */
function trailing_slash_url_inbound_alter(&$path, $original_path, $path_language) {
  if (substr($original_path, -1) == '/') {
    // Remove trailing shash.
    $original_path_no_slash = rtrim($original_path, '/');
    // Lookup the path alias.
    if ($source = drupal_lookup_path('source', $original_path_no_slash, $path_language)) {
      $path = $source;
    }
  }
}
πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States furamag

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    I'm closing it because the issue was created a long time ago without any further steps.

    if you still need it then raise a new one.
    thanks

Production build 0.71.5 2024