Hi

If the primary service failed to deliver a shorten url, the module try to use the secondary service.

The secondary service is used only if the return of the first is null (shorten.module : l.152). But if the first service isn't found, the module return the original url, and so the secondary service can not be used.

I think the module should test if the url is null and not egal to the original :

   //If the primary service fails or return the original url, try the secondary service.
   if (!$url || $url == $original) {
    $service = variable_get('shorten_service_backup', 'TinyURL');
    if (isset($services[$service])) {
      $url = _shorten_get_url($original, $services[$service]);
    }
    //If the secondary service fails, use the original URL.
    if (!$url) {
      $url = $original;
    }
  }

Best

CommentFileSizeAuthor
#1 shorten.module.patch608 bytesJulienD

Comments

JulienD’s picture

StatusFileSize
new608 bytes

I join a patch file done on the 6.x-1.x-dev

icecreamyou’s picture

Status: Active » Reviewed & tested by the community

You're quite right. Thanks for the patch, and it looks like it should work. I think a better solution might be to just return NULL in _shorten_get_url() on line 225 of shorten.module though, since that's what the current code in shorten_url() (rightfully) expects. I'll commit this hopefully later today.

icecreamyou’s picture

Title: Using of the secondary service when the first is broke » Use the secondary service instead of the original URL when the first service returns nothing
Status: Reviewed & tested by the community » Fixed

Committed a fix to dev. Thanks.

Status: Fixed » Closed (fixed)

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