fb.module uses hook_url_outbound_alter() to change links. So for example a link to 'node/123' might become apps.facebook.com/appname/node/123, when drupal is serving up an application on facebook.

When node/123 has an alias, this fails completely. The hook_url_outbound_alter() is called as expected, and it changes the $path as expected. Then, the code in common.inc url() does this:

    $alias = drupal_get_path_alias($original_path, $language); // NOTE: $original_path!!!
    if ($alias != $original_path) { // NOTE: $original_path!!!
      $path = $alias;
    }

The code above checks the non-altered $original_path instead of the altered $path. In both lines it should check $path. Otherwise, as I said at the beginning, hook_url_outbound_alter() has no effect at all.

In practice, this means a drupal menu renders on a facebook canvas page. All the links without aliases work as expected, going to say app.facebook.com/whatever/whatever. Whereas the menu items with aliases do the wrong thing (open your drupal site inside of an iframe inside apps.facebook.com/...)

Now, here's the really juicy bit. As I said above, changing $original_path to $path in a couple places would solve my biggest problem. However, I believe the order in which drupal alters urls and applies aliases is bass-ackwards. Here's an excerpt from doc:

$path: The outbound path to alter, not adjusted for path aliases yet. It won't be adjusted for path aliases until all modules are finished altering it, thus being consistent with hook_url_inbound_alter(), which adjusts for all path aliases before allowing modules to alter it. This may have been altered by other modules before this one.

It is correct that inbound operations and outbound should have the opposite order. However they should be switched from what they are today. Let's say I have a node, node/123 and I give it an alias foobar/123. When on a canvas page, I would like my alter function to end up with apps.facebook.com/appname/foobar/123. But there's no way I could return that URL today, because my outbound hook is passed "node/123". I'm suggesting here that it should be passed "foobar/123" instead.

And failing that bigger change, it is important that at least the modest patch changing $original_path to $path be implemented.

Comments

Anonymous’s picture

Version: 7.x-dev » 8.x-dev
Priority: Major » Normal

Is this true for 8.x?

Dave Cohen’s picture

I have not actually tested 8.x, but just looking at common.inc, it looks the same.

jherencia’s picture

I agree, current implementation does not follow the correct order.

dawehner’s picture

Status: Active » Fixed

You can define an outbound path processor which does what you need.

Status: Fixed » Closed (fixed)

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