Problem/Motivation

If in Path breadcrumbs settings the option:

“Use module breadcrumbs render function” is checked

All the links get broken this way:

localhost/sandbox/test/mydrupal/sandbox/test/mydrupal/admin/config

localhost/sandbox/test/mydrupal/sandbox/test/mydrupal/node/3

www.example.com/subdirectory/mydrupal/subdirectory/mydrupal/about-us

etc.

I have tested on localhost and on the server with path_breadcrumbs module versions:
7.x-2.0-beta17
7.x-3.x-dev

Drupal versions:
7.18, 7.19

It is similar to the issue http://drupal.org/node/1645110 (link to homepage when my drupal not in root folder of server) but unlike it, it does not happen when the link points to , in fact that is the link that does not get broken.
The solution for this issue (#14) is no longer applicable for current versions.

Proposed resolution

After some inquires and tests on the module, I spotted that in the path_breadcrumbs.module the call to the l() function uses as argument not an internal path, (admin/config, node/3 etc.), but:

sandbox/test/mydrupal/admin/config

sandbox/test/mydrupal/node/3

One can argue that if you change the Base URL in the settings.php file, it could be resolved, but when the “Use module breadcrumbs render function” is unchecked it works as normally. Also it could be discussed that subdirectories should not be included in the internal path.

So I spotted this line in the path_breadcrumbs.module, (approximately in line 278 in 7.x-2.0-beta17 and line 318 in 7.x-3.x-dev)

function path_breadcrumbs_breadcrumb($variables) {
...

        else {
          // HREF param can't starts with '/'.
          $href = stripos($matches[1], '/') === 0 ? drupal_substr($matches[1], 1) : $matches[1];
        }

Then I substituted 1 with drupal_strlen($base_path)

        else {
          // HREF param can't starts with '/'.
          $href = stripos($matches[1], '/') === 0 ? drupal_substr($matches[1], drupal_strlen($base_path)) : $matches[1];
        }

It solves the problem for me, anyway I would like to know if other people have the same problem.

CommentFileSizeAuthor
#10 path_breadcrumbs-1893878-10.patch2.14 KBOnkelTem

Comments

sakseiw’s picture

I have Same problem.
Proposed solution works for me too.

Anthony Goode’s picture

Hi sakseiw,

Thank you for your feedback!

spleshka’s picture

Still can't reproduce it. Can you provide some tests for that?

Anthony Goode’s picture

I reproduced it with a new installation of Drupal 7.20 from scratch (standard and only English).
The url of the drupal site test was: localhost/drupal/dummysites/drupal720
After that I installed and enabled the following modules:

  • ctools (7.x-1.2)
  • token (7.x-1.5)
  • module_filter (7.x-1.7 - this module is optional)
  • l10n_update (7.x-1.0-beta3)
  • path_breadcrumbs (7.x-2.0-beta17)

It worked well until I used localization update to download the .po files of a new language (in my case Spanish). Then it does not matter which language is set as default, after that if you click on a breadcrumb link an error saying that Page not found appears.

E.g.:

Page not found
The requested page "/drupal/dummysites/drupal720/drupal/dummysites/drupal720/admin/config" could not be found.

Then if I change the line 278 in the path_breadcrumbs.module file as I posted before (see proposed solution), links work well again.

If you can not reproduce the error, please let me know.

Thanks for your interest in investigating the error!
I also want to congratulate you for your great work in the developing and maintenance of this module, for me it is simple to use, powerful and so the best dealing with breadcrumbs.

spleshka’s picture

Issue tags: -Quick fix

Thanks for your report :) But this is not "Quick fix." I have to dig dipper and try to understand why problem occurs and avoid similar bugs in the future.

kalabro’s picture

Title: Broken links when Use module breadcrumbs render function is checked (proposed solution) » Duplicated path prefix in urls when using Path Breadcrumbs render function
Version: 7.x-2.0-beta17 » 7.x-3.x-dev
Category: feature » bug
Status: Active » Needs review

Guys, that was really difficult to reproduce!
I finally found it when:

  • installed Drupal in subfolder
  • set another language as default
  • disabled URL language detection
  • set relative URL in my Path Breadcrumb item (node for example).

First commit is here: http://drupalcode.org/project/path_breadcrumbs.git/commitdiff/91f1307cec...

Please, test if it fixes your problem. Thanks!

May be related:
#1998096: Path breadcrumbs leads to a "Page not found" even when in Administration
#1949866: Wrong breadcrumb link with url prefix.

HakS’s picture

I had same problem,
#6 worked for me, thank you @kalabro

kalabro’s picture

Status: Needs review » Fixed

Sould be fixed in 7.x-3.0-beta4 release.

Status: Fixed » Closed (fixed)

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

OnkelTem’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new2.14 KB

This is new patch which make PB behave more like core l() function when working with languages, taking into account real URL language, rather then UI language ($langauge_url vs $language).

  • kalabro committed 6093b89 on 7.x-3.x authored by OnkelTem
    Issue #1893878 by OnkelTem: Use $language_url just like l() does.
    
kalabro’s picture

Status: Needs review » Fixed

Thank you @OnkelTem! It will be in PB 3.1 release.

Status: Fixed » Closed (fixed)

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