This is an extension of an issue reported under the Forward module - http://drupal.org/node/966388. As reported in that issue, when trying to use the Forward service link in Service Issues an extra "node/" is added to each link, which results in a page not found error.

The link created is: http://localhost:8082/forward?path=node%2Fcontent%2Fabout
Which creates a forward page that points to: http://localhost:8082/node/content/about - which doesn't exist
It should point to: http://localhost:8082/content/about

However, upon installing the 6.x-2.x-dev version (2010-Nov-23) version of the Service Links module I have discovered that the same problem is present in the Print HTML, Print Mail and Print PDF services. This indicates to me that the problem needs to be addressed in the Service Links module.

For example, the Print Mail service creates the broken link: http://localhost:8082/printmail/node%2Fcontent%2Fabout

I suspect that the problem is partly due to the fact that I am using URL Aliases on my site but I cannot see how to fix it.

Grateful if this matter could be addressed.

Paul

Comments

TheCrow’s picture

StatusFileSize
new921 bytes

Hi Paul,
thanks for report it, cold you test the patch attached?

phiscock’s picture

Not quite working. It still inserts an extra preceding forward slash (where it inserted node before) which breaks the links. For example:

Paul

TheCrow’s picture

cold you print the result of this:

print url('/');
phiscock’s picture

<?php
print url('/');
?>

prints:
//

maximiliam’s picture

StatusFileSize
new578 bytes

This patch should work.

maximiliam’s picture

StatusFileSize
new602 bytes
nedjo’s picture

Status: Active » Needs work
StatusFileSize
new1.43 KB

We shd fix this in both places is appears. We can use url('') to get the base prefix. Updated patch attached.

phiscock’s picture

Sorry but that patch doesn't work either. In this case it strips too many forward slashes producing:

http://localhost:8082/printmail/contentabout

where it should be:

http://localhost:8082/printmail/content/about

Paul

TheCrow’s picture

Don't know why u have an output like that, but this should work:

$query = str_replace(preg_replace('/\/\/|(\?q\=)\/+/', '\1', url('/')), '', url("node/$node->nid"));

I can't provide a patch now, im sorry

phiscock’s picture

It still inserts an extra forward slash as before with that change.

nedjo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

Problem with patch in #7 was use of str_replace() since the prefix could be just / and was replaced in all instances.

Revised patch instead uses strlen and substr to strip the prefix.

phiscock’s picture

Good news and bad news. The good news is that the latest patch results in the right address.

However, the Print services are still not working because they are choking on the use of the escaped character %2F in the address instead of / (e.g. http://localhost:8082/printmail/content%2Fabout).

Paul

nedjo’s picture

Thanks for the testing feedback. The remaining issue appears to be a distinct bug, presumably caused by the use of encoded-query instead of just query for this particular service. Please look for a relevant issue or open a new one.

TheCrow’s picture

StatusFileSize
new960 bytes

Unfortunately every solution which use url('') doesnt work well for not-clean urls

i reproduced the same output of #4 adding an url alias '/' for 'node'

the patch attached work well for me with and without clean urls...

phiscock’s picture

The patch in #14 seems to produce the same problem as I reported in #12 so still doesn't work for my purposes.

Paul

TheCrow’s picture

Status: Needs review » Fixed

good news @phiscock,
how @ndejo said in #13, that's just a tag's trouble, i committed all the fix, if there are still troubles, reopen this issue, thanks

Status: Fixed » Closed (fixed)

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

carvalhar’s picture

Status: Closed (fixed) » Active

hi,

i'm using i18n and for the non default languages it's getting a wrong path as :
http://localhost/client/en/client/en/comunicado/release-video

So i'm checking for the language and correcting it, but of course this isn't the best approach.

	if(i18n_get_lang() == 'en'){
		$query = drupal_get_path_alias("node/$node->nid");
	}
	else {
		$query = preg_replace('/^\//', '', str_replace(preg_replace('/\/\/|(\?q\=)\/+/', '\1', url('/')), '', url("node/$node->nid")));
	}
TheCrow’s picture

Status: Active » Closed (fixed)