The node_search function in node.module should produce absolute URLs, otherwise the feeds produced by the OpenSearch module have broken links at the item level.

This change to line 724 fixes things:
$results[] = array('link' => url('node/'. $item->sid, NULL, NULL, TRUE),

CommentFileSizeAuthor
#5 node_search_0.patch835 byteshickory

Comments

webchick’s picture

Project: Drupal core » OpenSearch feed
Version: 4.7.3 » master
Component: node.module » Code

Hm. I think it makes more sense to fix this in OpenSearch module. It doesn't really make sense for core to require users to initiate HTTP requests for search results, as that's inconsistent with the way everything else is output.

fiLi’s picture

I agree. This kind of takes the point out of OpenSearch, doesn't it?

Is there a quick fix for that? I'm no PHP coder, but isn't this a one line replace?

hickory’s picture

I'm not sure what's meant by "require users to initiate HTTP requests for search results" - this fix just changes the links in search results so that they use absolute URLs rather than relative URLs.

I tried to fix it in opensearch.module, but couldn't find anywhere to do so, as it uses the _search hook in node.module to produce the search results.

moshe weitzman’s picture

Priority: Normal » Critical

I'm not sure where to fix this. But the problem gets worse if run drupal in a subdir. Both the xml:base link and the relative search result links include the subdir so the links simply aren't valid. for an example, see http://www.relayforlife.org/relay/opensearch/node/hope

hickory’s picture

Project: OpenSearch feed » Drupal core
Version: master » 5.x-dev
Component: Code » node system
Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new835 bytes

This is breaking livesearch as well. Here's an actual patch.

Steven’s picture

Moshe: The links in that opensearch feed are messed up inside the XML itself... the base url is being prefixed to a url()-generated relative URL. Which piece of code is doing that?

moshe weitzman’s picture

@Steven - sorry, i had some local modifications that i forgot about. i just reverted to latest 4.7 branch.

Now, the links at http://www.relayforlife.org/relay/opensearch/node/hope still don't look right and fail in some RSS readers (Vienna on OSX, bloglines.com). But some work OK (google reader).

Note that xml:base has a suspicious slash at the end which is added by opensearch_feed()

Steven’s picture

Status: Needs review » Fixed

I don't think the xml base is weird... it's the url to url('', NULL, NULL, TRUE);. I.e. the $base_url. The relative links have a starting slash because they are prefixed with $base_path.

However, if some readers and such have problems with relative links, it's indeed better to switch to absolute. We have no idea what happens to the data generated by search_data().

Committed to HEAD and changed the user results too, for consistency.

Anonymous’s picture

Status: Fixed » Closed (fixed)