Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
28 Jun 2010 at 14:39 UTC
Updated:
13 Jul 2010 at 19:40 UTC
Jump to comment: Most recent file
This is a performance improvement (and corrects an API oversight) for modules that use hook_url_outbound_alter().
Since altering the path is generally done based on the entity, these functions have to re-load the entity. If we attach it to the $options array sent to url(), then we should see performance improvements for that alter hook.
Dave Reid and I discussed this and don't consider this an API change so much as a more correct implementation of the intent of entity_uri().
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 839520-entity-uri.patch | 1.42 KB | agentrickard |
Comments
Comment #1
agentrickardAnd a patch.
Comment #2
agentrickardTagging.
Comment #3
dave reidThis is clearly an oversight in entity_uri that will also make modules that want to rewrite specific entity uris. This is more specific that changing the uri callback of the entity/bundle itself.
Comment #4
dave reidComment #5
moshe weitzman commented+1 from me as well. a lesser version of this was requested in #823428-8: Impossible to alter node URLs efficiently
Comment #6
agentrickard@moshe - I deliberately spun this off from that issue.
Comment #7
dries commentedCommitted to CVS HEAD. Thanks.
Comment #8
effulgentsia commentedAwesome! I'm glad this went in, and there may be some great use-cases for it. Note, however, that it only works when entity_uri() is called, so if you want core doing so reliably, please share that opinion on #823428: Impossible to alter node URLs efficiently. Also note, however, that every implementation of hook_url_outbound_alter() slows down every call to url(), because in PHP, stack calls aren't free, even if the function called exits early. entity_uri() deliberately supports per-entity overriding during entity load via the $entity->uri property: see code comments within entity_uri(). Doing so during entity load also means it's cacheable if you use http://drupal.org/project/entitycache.
Comment #9
agentrickardI see that now and wonder if it could be documented better that hook_entity_info_alter() can (and should) be used in place of custom_url_alter() in many cases (like mine).
Comment #10
rfayPlease summarize the impact of this API change and I'll send out a note.
Thanks,
-Randy
Comment #11
agentrickardWell, from just this change, the impact is that entity information is now passed to url(), which means that implementations of hook_url_outbound_alter() will be passed the entity type and data, so that they should not need to re-load the entity before processing the url() request.
In practice, it means that instead of checking the URL syntax to see it you need to alter it, you just check the type. E.g.
However, to get the full benefit of this, #823428: Impossible to alter node URLs efficiently has to go in. And doing that means we can use hook_entity_info_alter() instead of hook_url_outbound_alter() in most cases.
Comment #12
moshe weitzman commented@rfay - there is no api change here. no announcement needed.
Comment #13
effulgentsia commentedI'm not sure why this issue has the "API change" tag. I don't think a note needs to go out to the dev list for this one. We will need to update http://drupal.org/node/224333#hook_url_outbound_alter, but as per #11, I think we should only do so after we have resolution on #823428: Impossible to alter node URLs efficiently.
Comment #14
moshe weitzman commentedThe word "API change" is pretty ambigous as used in Drupal. If an API enhancement and an interface change (i.e. function arguments, return value) have the same name, then we are hopeless. This issue is an API enhancement.
Comment #15
effulgentsia commentedI added docs requested in #9 to the re-roll in #823428-34: Impossible to alter node URLs efficiently.
Removing the "API change" tag from this issue, as I agree with Moshe that that tag should be reserved for BC breaks. We have an "API addition" tag, though I'm not sure what the utility of it is.