I get two of these in the watchdog log each time I create a node:

CURL failed to return an abbreviated URL from .

with details:

Error: Please enter a valid URL to shorten

I suspect this is because I've not set up any API keys -- in which case, the module should just warn with hook_requirements() and not keep trying to operate.
Alternatively, it could be because I'm on localhost.

(A side issue -- does the module really get a shortened URL on the offchance I need the token, for every single node save? That seems rather wasteful if so.)

Comments

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

I suspect this is because I've not set up any API keys -- in which case, the module should just warn with hook_requirements() and not keep trying to operate.

You should not be able to select any of the services that require API keys if you haven't entered API keys. Which service are you trying to use?

Alternatively, it could be because I'm on localhost.

It will work fine on localhost as long as your local instance has internet access.

A side issue -- does the module really get a shortened URL on the offchance I need the token, for every single node save? That seems rather wasteful if so.

If you enable that token in the module's settings, then yes, it does. That has nothing to do with Shorten URLs -- it's just the way Token works. Every single token is built and retrieved every time it *might* be needed. However, Shorten URLs caches the URLs it retrieves, so you generally won't notice any related performance issues.

joachim’s picture

> You should not be able to select any of the services that require API keys if you haven't entered API keys. Which service are you trying to use?

I'm not trying to use any service! I installed the module to see if I could use its API in some custom code, and now when I save new nodes I get that message.

> However, Shorten URLs caches the URLs it retrieves, so you generally won't notice any related performance issues.

What I meant by 'wasteful' is that it's creating a shortened URL at say bit.ly which is going to be thrown away. These are surely finite!

icecreamyou’s picture

I'm not trying to use any service!

The module uses (mostly third-party) URL shortening services like bit.ly to shorten URLs. Even if you didn't set one explicitly, there should be a default one and a backup one enabled in the module's settings.

What I meant by 'wasteful' is that it's creating a shortened URL at say bit.ly which is going to be thrown away. These are surely finite!

Sure, but you need the short URL to make a short URL token, and there's no way to tell whether the token is actually going to be used before the Token module asks for it. It's an issue with the way the Token module is designed, not an issue with Shorten URLs. However, if you're not using that token, you can turn it off in the module's settings.

icecreamyou’s picture

Any thoughts on how I might reproduce it? I haven't seen this error before and everything seems to be working for me.

icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
joachim’s picture

Status: Closed (cannot reproduce) » Active

I'm getting more of this sort of thing when I publish nodes in bulk via node admin:

warning: file_get_contents(http://is.gd/api.php?longurl=https://www.snp.org/node/10632): failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway in /home/snp-web/htdocs/sites/all/modules/contrib/shorten/shorten.module on line 378.

I still have no API keys set up... I would expect shorten module in this instance to remain mute rather than try and contact things it doesn't have!

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

is.gd doesn't need an API key. There is no contacting anything it doesn't have.

Also you should upgrade to 1.12 - at the very least the errors will probably be more useful.

A 502 error is a server error, but "failed to open stream" usually means something is blocking outbound requests. Can your local server make HTTP requests?

joachim’s picture

Title: log warnings if no api keys set up » log warnings when nodes saved
Version: 6.x-1.11 » 6.x-1.12
Status: Postponed (maintainer needs more info) » Active

> Can your local server make HTTP requests?

Yes, definitely.

(Though shouldn't you be using drupal_http_request() rather than file_get_contents()?

> There is no contacting anything it doesn't have.

Well what I mean (probably) is that I've not

> Also you should upgrade to 1.12

Just checked -- that's the version I was on in fact.

Is there a way to prevent attempts at shortening? I see that 'Generate a shortened URL for nodes for use as tokens' was selected which is probably the cause. But there's 'Shorten aliased URLs where possible' too and that's rather vague...

icecreamyou’s picture

shouldn't you be using drupal_http_request() rather than file_get_contents()?

The D7 branch uses drupal_http_request(), but that function doesn't support the ability to time out in D6, which could potentially lead to extremely long page load times if it was used. The D7 branch handles requests a little more gracefully than the D6 branch in general.

> There is no contacting anything it doesn't have.

Well what I mean (probably) is that I've not

Missing the rest of that sentence?

Is there a way to prevent attempts at shortening? I see that 'Generate a shortened URL for nodes for use as tokens' was selected which is probably the cause. But there's 'Shorten aliased URLs where possible' too and that's rather vague...

Disabling "Generate a shortened URL for nodes for use as tokens" should make it so that URLs are only shortened if you explicitly ask for them to be shortened by calling the API, using the UI provided at /shorten or in the Shorten URLs block, or using some other module that calls the API. The "Shorten aliased URLs where possible" setting just means that for example if you try to shorten /node/32, the module will look for an alias of /node/32 instead.

I'm really not sure what else to tell you. I can't reproduce this and I haven't heard of it happening before. The shortening service you're using (is.gd) appears to be functioning fine, so if your server configuration isn't blocking outbound HTTP requests I'm not sure what would cause this.

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

Any additional information? Any difference with other shortening services?

icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)