Closed (fixed)
Project:
Shorten URLs
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Mar 2010 at 19:20 UTC
Updated:
29 Apr 2010 at 00:00 UTC
Hi,
I just tried to save a node of a special content type and got this error:
* warning: file_get_contents(http://api.bit.ly/shorten?version=2.0.1&format=xml&history=1&login=MYLOGIN&apiKey=MYAPI-KEY&longUrl=http://www.MY-SITE.com/ernaehrungstagebuch/tobias/mein-einag-in-ernaehrungstagebuh): failed to open stream: HTTP request failed! in /srv/www/vhosts/MY-SITE.com/httpdocs/sites/all/modules/shorten/shorten.module on line 324.
* warning: strpos(): Offset not contained in string in /srv/www/vhosts/MYSITE.com/httpdocs/sites/all/modules/shorten/shorten.module on line 361.
Any idea what this is???? It seems to appear just with this one content type because while I puplished nodes of other content types no error message appeared.
Greez,
Tobias
Comments
Comment #1
tobiberlinI installed Taxonomy Autotagger and since then this error message appears. Obviously there is no connection created to the bit-ly service as I realized that within an automatically published Tweet on my Twitter account using rules and the [node:url]-token the original URL is used not the shortened one. Could it be that Shorten URL and Autotag are intefering?
Comment #2
tobiberlinComment #3
tobiberlinOk... I realized that this error message appears as well with a project on which Autotag is not installed... :-(
Comment #4
icecreamyou commentedTry it with a URL shortening service other than bit.ly. Also try shortening a URL from example.com/shorten. If it doesn't work, your server probably doesn't support filestreams, which is extremely unusual but means that you won't be able to use the Shorten URLs module. If the option is available in your settings, use cURL instead, but I would be surprised if you have cURL and not filestreams.
Comment #5
tobiberlinThe module worked just fine during a longer time and suddenly started to fail. Maybe it has something to do with bit.ly - I just changed the service to "This site" and it seems to work fine now. Thank you for your support.
Comment #7
alan d. commentedJust confirming that this is a bug in the code from version 6.x-1.5, but I am not reopening as I haven't looked at HEAD to see recent changes.
The module should test the result from any service and if NULL / FALSE (aka no curl support or open remote files), it should not cache the result and return the original URL.
Cheers
Comment #8
icecreamyou commentedWhen an attempt to shorten a URL fails, Shorten URLs 6.x-1.6 and later only caches the original URL for 30 minutes. (When shortening succeeds, the URL is cached for 3 weeks.)
Comment #9
alan d. commentedCool, but the code from 1.5 was throwing errors, with cURL enable, cURL selected, but server configuration meaning that the cURL request itself failed. [edit: the FALSE result was being passed to string functions]
Comment #10
icecreamyou commentedSucks.
...and now that I'm done being snarky, you're actually totally right, when cURL fails FALSE could get passed to drupal_substr(). I just fixed that in dev. :-P
Comment #11
alan d. commentedSorry for trying to help eliminate the same error as in:
which was the direct result of a cURL request that had an error. It returns FALSE and not a string if cURL itself has an error. Simple really, same as file_get_contents() or whatever you use with the file() approach. A network error will result in the same response from either method and both continue on unchecked into the parsing functions that expect a string and then trigger off the error. So I hope the check you implemented was on both....
Anyway, enough time on this.
Comment #12
icecreamyou commentedI'm just being sarcastic, I don't mean any offense. You were right, there was a problem. I thought I fixed it yesterday but it turns out I missed another place where the problem could happen, in _shorten_xml() which only gets run for bit.ly, j.mp, and retwt.me. I'm not at my desk but I'll fix that later today.
Comment #13
icecreamyou commentedCommitted to dev. Thanks for the report.
Comment #14
alan d. commented:)
Thanks for the module by the way. It does the job nicely!