summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 15:13:38 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-09-30 15:13:38 -0700
commitaed4de70c7bcaddb63f4b7eedec73f9802a88791 (patch)
tree66e6b7815be236b08d8542bb171bfbf39dedd1c1 /includes
parent777322657a198eed29e75ea28928f8d91e37aa0b (diff)
downloadbrdo-aed4de70c7bcaddb63f4b7eedec73f9802a88791.tar.gz
brdo-aed4de70c7bcaddb63f4b7eedec73f9802a88791.tar.bz2
Issue #1057242 by drunken monkey: Change notice for entity_uri() should not use ->uri (was ->uri doesn't match the contract for uri callbacks).
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc58
1 files changed, 22 insertions, 36 deletions
diff --git a/includes/common.inc b/includes/common.inc
index da0340b3f..355ef379b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -7572,44 +7572,30 @@ function entity_prepare_view($entity_type, $entities, $langcode = NULL) {
* uri of its own.
*/
function entity_uri($entity_type, $entity) {
- // This check enables the URI of an entity to be easily overridden from what
- // the callback for the entity type or bundle would return, and it helps
- // minimize performance overhead when entity_uri() is called multiple times
- // for the same entity.
- if (!isset($entity->uri)) {
- $info = entity_get_info($entity_type);
- list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
- // A bundle-specific callback takes precedence over the generic one for the
- // entity type.
- if (isset($info['bundles'][$bundle]['uri callback'])) {
- $uri_callback = $info['bundles'][$bundle]['uri callback'];
- }
- elseif (isset($info['uri callback'])) {
- $uri_callback = $info['uri callback'];
- }
- else {
- $uri_callback = NULL;
- }
+ $info = entity_get_info($entity_type);
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
- // Invoke the callback to get the URI. If there is no callback, set the
- // entity's 'uri' property to FALSE to indicate that it is known to not have
- // a URI.
- if (isset($uri_callback) && function_exists($uri_callback)) {
- $entity->uri = $uri_callback($entity);
- if (!isset($entity->uri['options'])) {
- $entity->uri['options'] = array();
- }
- // Pass the entity data to url() so that alter functions do not need to
- // lookup this entity again.
- $entity->uri['options']['entity_type'] = $entity_type;
- $entity->uri['options']['entity'] = $entity;
- }
- else {
- $entity->uri = FALSE;
- }
+ // A bundle-specific callback takes precedence over the generic one for the
+ // entity type.
+ if (isset($info['bundles'][$bundle]['uri callback'])) {
+ $uri_callback = $info['bundles'][$bundle]['uri callback'];
+ }
+ elseif (isset($info['uri callback'])) {
+ $uri_callback = $info['uri callback'];
+ }
+ else {
+ return NULL;
+ }
+
+ // Invoke the callback to get the URI. If there is no callback, return NULL.
+ if (isset($uri_callback) && function_exists($uri_callback)) {
+ $uri = $uri_callback($entity);
+ // Pass the entity data to url() so that alter functions do not need to
+ // lookup this entity again.
+ $uri['options']['entity_type'] = $entity_type;
+ $uri['options']['entity'] = $entity;
+ return $uri;
}
- return $entity->uri ? $entity->uri : NULL;
}
/**