Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
4.73 KB

Here is a first patch, will fail without #1615236: Merge entity controller interfaces, document and add default entity class definition.

Had to do some funky stuff in the tests, those test entities in field.module should imho be merged with entity_test.module and the entity property test moved to the entity.module as well.

Status: Needs review » Needs work

The last submitted patch, remove-entity-label-1615240-1.patch, failed testing.

aspilicious’s picture

Don't we need the wrapper function stuff for menu callbacks?

Berdir’s picture

Yeah, just read that myself in the other issue.

So it should be renamed (entity_page_label?) and the $entity_type argument removed, we don't need that one anymore. Also, it should just be a wrapper for $entity->label().

fago’s picture

Issue tags: +Entity system, +sprint

#4 sounds good to me

Berdir’s picture

Status: Needs work » Fixed

Updated the patch. Will still fail until the entity controller issue is commited.

Berdir’s picture

Status: Fixed » Needs review
FileSize
5.15 KB

Uh, what happened there?

Status: Needs review » Needs work

The last submitted patch, remove-entity-label-1615240-6.patch, failed testing.

aspilicious’s picture

Will need a reroll I guess

Berdir’s picture

Status: Needs work » Needs review

#7: remove-entity-label-1615240-6.patch queued for re-testing.

Berdir’s picture

No, not necessary.

aspilicious’s picture

Is there a reason for switching to entity_page_label. Whats wrong with entity_label. I don't think it should be renamed because it's depricated in most cases.

fago’s picture

Is there a reason for switching to entity_page_label. Whats wrong with entity_label. I don't think it should be renamed because it's depricated in most cases.

It makes clear it's just there for menu-callbacks. If that needs goes away, entity_page_label() can be obviously removed as well. If we stay with entity_label() that's not so clear as it's supposed to be an API function, not a callback.

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

I wanted to rtbc but I still don't have a clue why the test additions in field module should be added...

aspilicious’s picture

Don't ment to rtbc yet...

Oh well it looks good and Berdir probably will answer my question soon ;)

Berdir’s picture

The changes in field_test are necessary because it is required to define a revision table when defining a revision key, that wasn't necessary before because we need to go through entity create for them now.

The current test changes are quite hackish, but that's the easiest way to fix those tests. There is an open issue about moving those tests and the entity types to entity.module/entity_test.module.

fago’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
5.1 KB

yep, having the controller requiring the revision table if revisions are used makes sense.

+++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
@@ -25,19 +25,19 @@ class UserEntityCallbacksTest extends WebTestBase {
-    $this->anonymous = drupal_anonymous_user();
+    $this->anonymous = entity_create('user', (array)drupal_anonymous_user());

The cast misses a space. Fixed that and tried to improve the comments of entity_page_label() a bit. Please review.

I guess we should fix drupal_anonymous_user() to return an entity as well? But that can be done in a separate issue.

Berdir’s picture

We can't change drupal_anonymous_user(), at least not yet. That function is currently using during session initializing, where the entity system is not yet available.

I have hope that re-factoring the session system to build upon Symfony will allow us to lazy-load the user object, which would make that possible.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.67 KB

Reviewed the changes in fago's patch, they look OK to me, see attached interdiff.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/entity/entity.module
@@ -414,31 +415,19 @@ function entity_uri($entity_type, $entity) {
+ * be used as callback, e.g. for menu title callbacks.

I think it should be: "used as A callback"

webflo’s picture

Status: Needs work » Needs review
FileSize
5.85 KB

Rerolled and fixed the docs for entity_page_label().

fago’s picture

FileSize
5.1 KB

Fixed #20 and rerolled the patch.

fago’s picture

Too late.. ;)

webflo’s picture

Found entity_label() reference in entity.api.php

webflo’s picture

Better docs: Entity::label() implements this logic. entity_page_label() not.

fago’s picture

Status: Needs review » Reviewed & tested by the community

Good catch, improvements look great. Back to RTBC then!

aspilicious’s picture

In docs we use full paths, so please change the following. Will leave this rtbc for now.

+++ b/core/modules/entity/entity.api.phpundefined
@@ -50,7 +50,7 @@
+ *     entity label. See also the Entity::label() method, which implements this

Should be Drupal\entity\Entity::label()

+++ b/core/modules/entity/entity.moduleundefined
@@ -414,31 +415,19 @@ function entity_uri($entity_type, $entity) {
+ * This is a wrapper for EntityInterface::label(). This function should only

Drupal\entity\EntityInterface

+++ b/core/modules/entity/entity.moduleundefined
@@ -414,31 +415,19 @@ function entity_uri($entity_type, $entity) {
+ * @see EntityInterface::label()

Same

12 days to next Drupal core point release.

fago’s picture

Status: Reviewed & tested by the community » Needs work

Um true. I don't like it very much as it makes the docs much more verbose, but that's a separate issue.

fago’s picture

Status: Needs work » Needs review
FileSize
6.11 KB

addressed #27.

webflo’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, I think this makes sense, including the re-naming of the "entity_page_label()" function, since otherwise that looks really tempting to call instead of $entity->label().

I had the same comment about jankiness of drupal_anonymous_user() that was in #17, but this was addressed in the issue as being not possible to clean up now.

Committed and pushed to 8.x. Thanks!

Berdir’s picture

Title: Remove entity_label() in favor of EntityInterface::label() » Change Notification for: Remove entity_label() in favor of EntityInterface::label()
Priority: Normal » Critical
Status: Fixed » Active

This needs a change record, no?

aspilicious’s picture

yes it does!

webchick’s picture

My mistake, thanks!

Berdir’s picture

There are a whole bunch of entity_label() related changes happening right now in various issues:

- Rename it, recommend using $entity->label()
- Add an optional langcode argument.
- Changing core to actually call it instead of e.g. $node->title, $term->name and so on.
- The label callbacks are changed/affected as well (e.g. removal of entity_type), langcode added ...

Not sure if and how we can combine all these changes into change records, make a single one, split it up somehow, ...?

fago’s picture

It's already mentioned that entity_label() is now deprecated in http://drupal.org/node/1400186. Once the entity_uri() patch is in as well, I think we can update this change notice to say they are gone. But as #35 points out there are more entity label related changes, so I think a separate change notice makes sense. (language, callbacks, ..) I'd prefer a single one that summarizes everything related to labels though. That way developers get not overloaded with change notices....

Related, I guess we should think about removing the label callback, but that's another issue.

amaia’s picture

Status: Active » Fixed
webchick’s picture

Title: Change Notification for: Remove entity_label() in favor of EntityInterface::label() » Remove entity_label() in favor of EntityInterface::label()
Priority: Critical » Normal

Restoring original issue properties.

WOOHOO. Thanks for the help, amaia!

amaia’s picture

Thank you webchick for walking me through it :)
I hope to be able to contribute some more from now on.

Status: Fixed » Closed (fixed)

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

fago’s picture

Issue tags: -sprint

Removing sprint tag.