When a site was moved from root to subdirectory (http://www.example.com to http://www.example.com/subdir), pathologic settings were edited: http://www.example.com/ and http://www.example.com/subdir/ were added to the "All base paths" and then caches cleared.

Pathologic was expected to process links properly. However, links that were absolute (e.g. href="http://www.example.com/sites/default/files/image.jpg"), were not corrected (i.e. to the expected "http://www.example.com/subdir/sites/default/files/image.jpg" ).

Comments

iva2k’s picture

Inspecting the code I was able to trace the problem to the way 'local_paths_exploded' is built in function _pathologic_filter(). The monster "if" statement inside "foreach ($local_paths as $local)" discards the case of "http://www.example.com/" because it has same 'host' but different 'path' as in $base_url_parts.

The fix that resolved this issue is adding

          || (
            // If this URI has a path, and…
            isset($parts['path']) &&
            // The path is different from the current path…
            $parts['path'] !== $base_url_parts['path']
          )

into that monster "if" statement before the closing paren, making it a bit bigger.

Garrett Albright’s picture

Status: Active » Fixed

I was able to replicate the bug and get a fix in place. It'll be in the next point release, or give the dev release a try. Thanks for bringing this to my attention!

iva2k’s picture

Status: Fixed » Needs work

Thanks, that was quick!

I tried the -dev, and it indeed fixed the case when http://www.example.com/... was not changed to http://www.example.com/subdir/...

However I have to reopen as the other case is broken now:
http://www.example.com/subdir/... becomes http://www.example.com/subdir/subdir/...
(actually I did not try it before, maybe it was broken all along).

stewart.adam’s picture

I can confirm that this issue is not resolved either. Patholigic is not fixing image paths for me when my Drupal install is in a subfolder (e.g. <img src="sites/default/files/image.png" />in a Full HTML block).

Garrett Albright’s picture

stewart.adam, does it look like you're having the same problem mentioned in this issue? If so, could you try downloading and running the 7.x-2.x-dev development release and let me know if it fixes the issue for you?

Garrett Albright’s picture

Issue summary: View changes
Status: Needs work » Fixed

Marking as fixed for now. Please update if needed.

Status: Fixed » Closed (fixed)

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