Support from Acquia helps fund testing for Drupal Acquia logo

Comments

estebanvalerio.h’s picture

Worked with Brolag

We did a search through all Drupal 8.x project and replaced the entity_uri() function for OBJECT->uri();

estebanvalerio.h’s picture

Status: Active » Needs review
fago’s picture

Issue tags: +Entity system, +sprint

Please watch out to not remove the sprint tags to avoid the issue moving out of our radar. :/

fago’s picture

Status: Needs review » Needs work

Conversions are straight forward and look good. But we also need to remove the function as well as all the references to it:

core/includes/common.inc: *     set if url() is invoked by entity_uri().
core/includes/common.inc: *     generated. Only set if url() is invoked by entit
core/modules/entity/entity.module:function entity_uri($entity_type, $entity) {
core/modules/entity/lib/Drupal/entity/Entity.php:   * @see entity_uri()
jcisio’s picture

Status: Needs work » Needs review
FileSize
3.15 KB
9.7 KB

This one fixes #4.

jcisio’s picture

Same as #5, with Entity::uri() being namespaced.

fago’s picture

Status: Needs review » Needs work
+++ b/core/includes/common.inc
@@ -2033,10 +2033,11 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
+ *   - 'entity_type': The entity type of the object that called url(). Only set
+ *     by Drupal\entity\Entity::uri() but is not used anywhere.

It's not used anywhere sounds like it is for nothing, but it isn't. It's available to hook_url_outbound_alter(). Thus, let's don't add that. (for $entity as well)

Once we already change the comment I think we can fix this part at the same time as well, i.e. let's remove the $entity_type option.

aspilicious’s picture

Status: Needs work » Needs review

do we need to keep a callback wrapper like we did with the entity label?

fago’s picture

Status: Needs review » Needs work

I don't think so. Where would you use that entity_uri callback? I can't imagine a use case and we don't have one in core.

jcisio’s picture

Status: Needs work » Needs review
FileSize
9.68 KB

Fix #7.

jcisio’s picture

Even better.

fago’s picture

Status: Needs review » Needs work
+++ b/core/includes/common.inc
@@ -2037,10 +2037,10 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
- *   - 'entity_type': The entity type of the object that called url(). Only
- *     set if url() is invoked by entity_uri().
- *   - 'entity': The entity object (such as a node) for which the URL is being
- *     generated. Only set if url() is invoked by entity_uri().
+ *   Modules can add more elements into this array to give more context. url()
+ *   does not directly use them, but hook_url_outbound_alter() implementations
+ *   may do. Drupal\entity\Entity::uri() sets two elements: 'entity' and
+ *   'entity_type'.

Why that docu change? It should read as previous, but just remove the entity type document and fix the reference to entity_uri. Then of course we have to fix the invocation to don't include the entity type as well.

jcisio’s picture

Status: Needs work » Needs review

I changed to correct that document, even I thought that it could be changed later when we removed the 'entity_type' in the $options array in #1643362: Remove 'entity_type' from Entity::uri()'s return (I've just created it).

Because 1/ Those values are not directly used in url() and l(). 2/ Any module can put more value into the $options array, I think this documentation change is needed.

fago’s picture

Status: Needs review » Needs work

Changing that documentation changes how that is supposed to be used, what needs discussion and a separate issue. So let's focus on deprecating entity_uri() here.

jcisio’s picture

Status: Needs work » Needs review
FileSize
9.57 KB

Ok that's exactly what I thought in #13. So reverting this documentation change.

(edit) PS: wrong filename, but patch is correct.

Berdir’s picture

Issue tags: -Entity system, -sprint, -dlatino, -drupalcr

#15: 1637342-15.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Entity system, +sprint, +dlatino, +drupalcr

The last submitted patch, 1637342-15.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
9.56 KB

Re-rolled.

fago’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good!

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Yay for less code. :D

However, this seems to no longer apply. ;(

corvus_ch’s picture

Assigned: Unassigned » corvus_ch
corvus_ch’s picture

Status: Needs work » Needs review
FileSize
10.58 KB

Make patch apply to current 8.x branch.

Status: Needs review » Needs work

The last submitted patch, 1618172-22.patch, failed testing.

corvus_ch’s picture

FileSize
10.58 KB

Make patch apply again.

aspilicious’s picture

Status: Needs work » Needs review

triggering the bot :) Thnx for working on this.

Status: Needs review » Needs work

The last submitted patch, 1618172-24.patch, failed testing.

aspilicious’s picture

You accidently removed too much :).

- $language = language_load($item->langcode);
- $uri = entity_uri('node', $node);
+ $uri = $node->uri();

The first line should stay!

corvus_ch’s picture

Status: Needs work » Needs review
FileSize
10.58 KB

Sorry for that one. Here is a new patch including the missing line.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, was RTBC before.

jvsouto’s picture

Looks good to me :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Lovely. Committed/pushed to 8.x.

Berdir’s picture

Updated http://drupal.org/node/1400186 to say "have been removed" instead of "will be removed" and added a reference to this issue.

BrockBoland’s picture

Needs issue summary

tim.plunkett’s picture

No need, it was committed.

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