Problem/Motivation

You cannot create a view and try to list rendered entities using relationship.

Steps to reproduce (based on Standard profile):

  1. Add an entity reference field named "field_content" to the "page" content type. Allow content > article references.
  2. Create and edit a content view.
  3. Add a relationship for "Content using field_content." or "Content referenced from field_content."
  4. The row style plugin is "Content" by default.
  5. Click on "Teaser" in order to change the view mode, nothing happens.
  6. You can't choose a view mode even if you don't want to actually use a relationship, just having one on your view triggers this.

The problem is a fatal AJAX error triggered when RowPluginBase::buildOptionsForm() calls RelationshipPluginBase::init() while providing a wrong argument type (Array instead of DisplayPluginBase).

Argument 2 passed to Drupal\views\Plugin\views\relationship\RelationshipPluginBase::init() must be an instance of Drupal\views\Plugin\views\display\DisplayPluginBase, array given, called in /app/web/core/modules/views/src/Plugin/views/row/RowPluginBase.php on line 93

Proposed resolution

Fix it, by passing along the relationship as needed and using it.

Remaining tasks

None.

User interface changes

None

API changes

None

 

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions Extract the test code + yml file out of the patch in #26
CommentFileSizeAuthor
#318 2457999-10.0.x-309.patch37.02 KBjoegraduate
#309 2457999-9.5.x-309.patch37.03 KBdavid.muffley
#300 2457999-300.patch38.38 KBLendude
#300 interdiff-2457999-298-300.txt467 bytesLendude
#298 2457999-298.patch37.79 KBLendude
#298 interdiff-2457999-296-298.txt1.56 KBLendude
#296 2457999-296.patch37.79 KBLendude
#296 interdiff-2457999-293-296.txt1.17 KBLendude
#293 2457999-2-293.patch37.16 KBalexpott
#293 284-293-interdiff.txt5.82 KBalexpott
#284 interdiff_282-284.txt5.08 KBdanflanagan8
#284 2457999-284.patch36.78 KBdanflanagan8
#282 interdiff_282FAIL-282PASS.txt16.73 KBdanflanagan8
#282 2457999-282.patch31.7 KBdanflanagan8
#282 2457999-282-FAIL.patch15.54 KBdanflanagan8
#281 interdiff_281FAIL-281PASS.txt16.15 KBdanflanagan8
#281 2457999-281.patch31.73 KBdanflanagan8
#281 2457999-281-FAIL.patch15.58 KBdanflanagan8
#280 test-view.png118.76 KBdanflanagan8
#276 9.3.x-2457999-276-FAIL.patch1000 bytesdanflanagan8
#267 9.3.x-2457999-267-views-relationship-rendered-entity.patch16.11 KBdonquixote
#267 9.2.x-2457999-267-views-relationship-rendered-entity.patch16.11 KBdonquixote
#267 9.1.x-2457999-267-views-relationship-rendered-entity.patch16.11 KBdonquixote
#267 8.9.x-2457999-267-views-relationship-rendered-entity.patch16.22 KBdonquixote
#259 cannot-use-relationship-2457999-259.patch16.11 KBBerdir
#249 cannot-use-relationship-2457999-249.patch16.17 KBPeacog
#247 cannot-use-relationship-2457999-247.patch16.16 KBPeacog
#244 cannot-use-relationship-2457999-244.patch16.15 KBlzimmerman_jr
#241 Screen Shot 2020-06-04 at 11.51.23 AM.png115.7 KBsharma.amitt16
#238 Screenshot 2020-06-04 at 11.22.12 AM.png230.72 KBsharma.amitt16
#236 cannot-use-relationship-2457999-236.patch16.15 KBBerdir
#233 cannot-use-relationship-2457999-233.patch16.04 KBnarendra.rajwar27
#223 2457999-223.patch16.2 KBLendude
#223 interdiff-2457999-222-223.txt4.5 KBLendude
#222 2457999-222.patch14.56 KBLendude
#220 drupal_8x_dev.sql_.gz1.11 MBplach
#220 Test__Content____Drupal_8_x.jpg430.42 KBplach
#216 2457999-215.patch14.55 KBLendude
#216 interdiff-2457999-194-215.txt3.24 KBLendude
#214 After patch file applied.png264.11 KBsathish.redcrackle
#214 Error on new drupal instance.png270.64 KBsathish.redcrackle
#214 Patch applied successfully.png96.63 KBsathish.redcrackle
#214 Error on new drupal instance.png270.64 KBsathish.redcrackle
#194 2457999-194.patch13.99 KBLendude
#194 interdiff-2457999-189-194.txt438 bytesLendude
#189 2457999-189.patch13.98 KBBerdir
#183 2457999-183.patch14 KBmarkpavlitski
#181 2457999-181.patch13.95 KBnevergone
#164 2457999-164.patch14 KBalexpott
#164 154-164-interdiff.txt2.67 KBalexpott
#154 2457999-153.patch14.63 KBjonathanshaw
#151 2457999-150.patch14.99 KBjonathanshaw
#151 interdiff-2457999-145-150.txt950 bytesjonathanshaw
#145 interdiff-2457999-138-145.txt1.93 KBjonathanshaw
#145 2457999-145.patch14.85 KBjonathanshaw
#138 interdiff-2457999-132-138.txt2.42 KBdagmar
#138 2457999-138.patch16.45 KBdagmar
#132 2457999-132.patch16.47 KBLendude
#132 interdiff-2457999-123-132.txt618 bytesLendude
#123 cannot_use_relationship-2457999-123.patch16.5 KBjibran
#123 interdiff-0542f8.txt788 bytesjibran
#122 2457999-122.patch16.52 KBLendude
#122 interdiff-2457999-119-122.txt898 bytesLendude
#119 2457999-119.patch16.5 KBLendude
#119 interdiff-2457999-113-119.txt5.81 KBLendude
#113 2457999-113.patch15.74 KBLendude
#113 interdiff-2457999-109-113.txt2.28 KBLendude
#110 2457999-109.patch14.62 KBLendude
#110 2457999-93-array-reroll.patch16.33 KBLendude
#110 interdiff-2457999-93-109.txt8.85 KBLendude
#93 2457999-93.patch16.34 KBalexpott
#93 63-93-interdiff.txt1.48 KBalexpott
#84 display_suite_renderer.patch2.92 KBayalon
#63 2457999-63.patch16.29 KBdawehner
#61 2457999-61.patch16.29 KBdawehner
#51 2457999-51.patch18.06 KBlokapujya
#51 2457999-51-test-only.patch4.86 KBlokapujya
#48 2457999-48.patch18.12 KBgeertvd
#37 interdiff.txt15.17 KBolli
#37 2457999-37.patch18.16 KBolli
#35 interdiff.txt3.11 KBolli
#35 2457999-35-tests.patch5.94 KBolli
#33 cannot_use_relationship-2457999-test-only-33.patch3.58 KBlauriii
#26 cannot_use_relationship-2457999-26.patch8.2 KBNitesh Sethia
#23 2457999-20.patch31.25 KBbfr
#23 2457999-20.patch31.25 KBbfr
#13 interdiff.txt7.99 KBolli
#13 2457999-13.patch15.86 KBolli
#9 interdiff.txt3.32 KBdawehner
#9 2457999-9.patch10.5 KBdawehner
#7 2457999-7.patch9.37 KBdawehner
#7 interdiff.txt671 bytesdawehner
#5 2457999-5.patch9.32 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

@lauriii
Are you sure this is not a duplicate of #2451789: Entity reference joins to the wrong base table in views. ?

lauriii’s picture

Yes. This existed before that other issue existed. I have also tested this with the patch from that other issue and it's still broken.

dawehner’s picture

Choose to use rendered entity

So, do we talk about header or footer? I seriously, tried to rebuild the view, but I don't see how you are able to select a relationship for header/footer

Feel free to atttach a exported configuration of a view.

lauriii’s picture

So I mean rendered views row. You are able to select the entity be used as relationship but it will still render the entity without relationship

dawehner’s picture

Status: Active » Needs review
FileSize
9.32 KB

I totally forgot that this feature existed. Btw. did you hacked the config directly? I got some failures while doing that.

Status: Needs review » Needs work

The last submitted patch, 5: 2457999-5.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
671 bytes
9.37 KB

Let's see how much less we have.

olli’s picture

Issue tags: +VDC
  1. +++ b/core/modules/views/src/Entity/Render/RendererBase.php
    @@ -85,15 +85,17 @@ public function query(QueryPluginBase $query) {
    -   * @param $result
    +   * @param array $result
    

    @param \Drupal\views\ResultRow[] $result?

  2. +++ b/core/modules/views/src/Entity/Render/RendererBase.php
    @@ -85,15 +85,17 @@ public function query(QueryPluginBase $query) {
    +      $entity = $relationship === 'none' ? $row->_entity : $row->_relationship_entities[$relationship];
           $entity->view = $this->view;
           $this->build[$entity->id()] = $view_builder->view($entity, $this->view->rowPlugin->options['view_mode'], $this->getLangcode($row));
    

    If the relationship is not required, the $entity might not be available.

  3. +++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
    @@ -47,12 +47,12 @@ public function query(QueryPluginBase $query) {
    -      $entity = $row->_entity;
    +      $entity = $relationship === 'none' ? $row->_entity : $row->_relationship_entities[$relationship];
    

    same as above

  4. I think we need to make a similar change to *Renderer::render()?
  5. How about adding ResultRow::getEntity($relationship)?
dawehner’s picture

FileSize
10.5 KB
3.32 KB

Thank you for you review!!

@param \Drupal\views\ResultRow[] $result?

Good idea. I still love that syntax.

How about adding ResultRow::getEntity($relationship)?

Good idea!

dawehner’s picture

Priority: Normal » Major

IMHO this is at least major

olli’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/src/Entity/Render/RendererBase.php
@@ -85,17 +85,19 @@ public function query(QueryPluginBase $query) {
+      if ($entity = $this->getEntity($row, $relationship)) {

I was thinking about ResultRow::getEntity() which would make this if ($entity = $row->getEntity($relationship)) { but this works too. =)

Needs work for the render methods (RendererBase::render(), TranslationLanguageRenderer::render()) that are using $row->_entity->id(). I guess the test passes because both entities there have the same id.

Do you think TranslationLanguageRenderer::query() and DefaultLanguageRenderer::getLangcode() should also use the relationship? Maybe pass it to constructor?

dawehner’s picture

Needs work for the render methods (RendererBase::render(), TranslationLanguageRenderer::render()) that are using $row->_entity->id(). I guess the test passes because both entities there have the same id.

Good point! Do you want to fix that?

Do you think TranslationLanguageRenderer::query() and DefaultLanguageRenderer::getLangcode() should also use the relationship? Maybe pass it to constructor?

You are absolutely right, they both need it as well.

olli’s picture

Status: Needs work » Needs review
FileSize
15.86 KB
7.99 KB

Added relationship parameter to render and getLangcode methods.

frob’s picture

Assigned: Unassigned » frob

I will review this patch this weekend.

Simplytest me came back with an error while applying the patch. Retesting.

frob queued 13: 2457999-13.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 13: 2457999-13.patch, failed testing.

frob’s picture

So it looks like I will reroll that patch this weekend

lauriii’s picture

Issue tags: +Needs reroll

Tutorial how to do a reroll: https://www.drupal.org/patch/reroll

bfr’s picture

Assigned: frob » bfr

I'll try to reroll it.

Nitesh Sethia’s picture

Assigned: bfr » Nitesh Sethia
Nitesh Sethia’s picture

Nitesh Sethia’s picture

Assigned: Nitesh Sethia » Unassigned
bfr’s picture

Status: Needs work » Needs review
FileSize
31.25 KB
31.25 KB

Rerolled.

The last submitted patch, 23: 2457999-20.patch, failed testing.

bfr’s picture

Not sure what happened there, seems like there were edits to issue during upload and somehow it attached duplicate?

However, i guess we can ignore the reroll since some other patch was submitted?

Nitesh Sethia’s picture

Status: Needs review » Needs work

The last submitted patch, 26: cannot_use_relationship-2457999-26.patch, failed testing.

The last submitted patch, 23: 2457999-20.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 26: cannot_use_relationship-2457999-26.patch, failed testing.

frob’s picture

Is this still broken? I was unable to reproduce it.

I created two content types
article
page

I added an entity reference field to the page that referenced the article.
I added article content and then I created a page that referenced that article content.

I created a view that adds the article content through the relation and then I set it to render full content and it worked.

So I am not sure what the steps are to reproduce.

dawehner’s picture

Issue summary: View changes
Issue tags: +Novice

I could totally imagine that we fixed that problem with some of our field rendering related work ... Does some mind to post a test only patch, to see whether its still broken?

lauriii’s picture

Status: Needs work » Needs review
FileSize
3.58 KB

Status: Needs review » Needs work

The last submitted patch, 33: cannot_use_relationship-2457999-test-only-33.patch, failed testing.

olli’s picture

Status: Needs work » Needs review
Issue tags: -Novice
FileSize
5.94 KB
3.11 KB

Removed RowEntityTest and 'entity' from modules. This fails locally so removing novice tag.

Status: Needs review » Needs work

The last submitted patch, 35: 2457999-35-tests.patch, failed testing.

olli’s picture

Status: Needs work » Needs review
FileSize
18.16 KB
15.17 KB

Another attempt to reroll #13. The interdiff is for #26.

frob queued 37: 2457999-37.patch for re-testing.

frob’s picture

I asked back in #31 if anyone was still able to reproduce this bug after some of the other changes that where done. I am still unable to reproduce. I would be able to help if someone said more about what the problem is and if it is still happening on the latest dev.

dawehner’s picture

Well, I guess @lauriii should be able to tell us, whether the problem still exists ...

lauriii’s picture

Seems to be still problem at least on some level since I'm not even able to configure which display mode should be printed after adding a relationship for the view. Patch attached to this issue fixes that and also makes it possible to print referenced rendered entities

frob’s picture

@lauriii, Do you have any cm yaml files that we can use to reproduce this? I think tests would also be good for this issue.

Cyberschorsch’s picture

I can also confirm that Patch #31 is fixing this issue.

frob’s picture

@Cyberschorsch, can you confirm that the error happens before you applied the patch.

dawehner’s picture

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
@@ -33,27 +35,62 @@ public function query(QueryPluginBase $query, $relationship = NULL) {
+
+  /**
+   * Gets the entity assosiated with a row.
+   *
+   * @param \Drupal\views\ResultRow $row
+   *   The result row.
+   * @param string $relationship
+   *   (optional) The relationship.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface|null
+   *   The entity might be optional, because the relationship entity might not
+   *   always exist.
+   */
+  protected function getEntity($row, $relationship = 'none') {
+    if ($relationship === 'none') {
+      return $row->_entity;
+    }
+    elseif (isset($row->_relationship_entities[$relationship])) {
+      return $row->_relationship_entities[$relationship];
+    }
+    return NULL;
   }

I'm curious whether we should move this function into a trait as \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity is the exact same code

dawehner queued 37: 2457999-37.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 37: 2457999-37.patch, failed testing.

geertvd’s picture

Status: Needs work » Needs review
FileSize
18.12 KB

Simple reroll for now.

I'm curious whether we should move this function into a trait as \Drupal\views\Plugin\views\field\FieldPluginBase::getEntity is the exact same code

Should that be something like RelationshipHandlerTrait? Or should it not be dedicated to Relationships and maybe be added in some existing trait (not finding a decent one).

Status: Needs review » Needs work

The last submitted patch, 48: 2457999-48.patch, failed testing.

dawehner’s picture

  1. index 697ae8a..ce96c49 100644
    --- a/core/modules/views/src/Entity/Render/ConfigurableLanguageRenderer.php
    
    --- a/core/modules/views/src/Entity/Render/ConfigurableLanguageRenderer.php
    +++ b/core/modules/views/src/Entity/Render/ConfigurableLanguageRenderer.php
    
    +++ b/core/modules/views/src/Entity/Render/ConfigurableLanguageRenderer.php
    @@ -44,7 +44,7 @@ public function __construct(ViewExecutable $view, LanguageManagerInterface $lang
    
    @@ -44,7 +44,7 @@ public function __construct(ViewExecutable $view, LanguageManagerInterface $lang
       /**
        * {@inheritdoc}
        */
    -  public function getLangcode(ResultRow $row) {
    +  public function getLangcode(ResultRow $row, $relationship = 'none') {
         return $this->langcode;
    

    Given that the language renderers cannot be extended this is much less of a BC break

  2. +++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
    @@ -33,27 +35,62 @@ public function query(QueryPluginBase $query, $relationship = NULL) {
    -  public function preRender(array $result) {
    +  public function preRender(array $result, $relationship = 'none') {
    

    Just curious, is it really valid to extend the list of parameters from an interface?

lokapujya’s picture

Status: Needs work » Needs review
FileSize
4.86 KB
18.06 KB

Reroll, and want to see the test only patch.

The last submitted patch, 51: 2457999-51-test-only.patch, failed testing.

no_angel’s picture

The last submitted patch, 51: 2457999-51-test-only.patch, failed testing.

dawehner’s picture

Issue summary: View changes
xjm’s picture

+++ b/core/modules/views/src/Tests/Plugin/EntityRowTest.php
@@ -0,0 +1,101 @@
+class EntityRowTest extends ViewKernelTestBase {

+++ /dev/null
@@ -1,71 +0,0 @@
-class RowEntityTest extends ViewKernelTestBase {

Are we renaming this existing test? If so can we not do that in this patch? It makes it difficult to review, which I'm trying to do to figure out how to reproduce this. See https://www.drupal.org/core/scope for more information about scoping core issues.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Needs steps to reproduce

Also, exact steps to reproduce through the UI would really help here.

NW for #56 though.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ciss’s picture

Steps to reproduce (based on Standard profile):

  1. Add an entity reference field named "field_content" to the "page" content type. Allow content > article references.
  2. Create and edit a content view.
  3. Add a relationship for "Content using field_content."
  4. Change row style plugin to "Content" and hit "Apply".
  5. An AJAX error occurs.

The AJAX error is caused by fatal error triggered when RowPluginBase::buildOptionsForm() calls RelationshipPluginBase::init() while providing a wrong argument type (Array instead of DisplayPluginBase).

ciss’s picture

+++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php
@@ -95,7 +95,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+          $relationship_handler->init($executable, $this->displayHandler, $relationship);

For the record: As far as I can tell this change alone fixed the problem caused by the steps listed in the previous comment.

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs steps to reproduce
FileSize
16.29 KB

Are we renaming this existing test? If so can we not do that in this patch? It makes it difficult to review, which I'm trying to do to figure out how to reproduce this. See https://www.drupal.org/core/scope for more information about scoping core issues.

Sure, but sometimes its sad when this was really the only reason this blocked the patch. Always remember that fixing bug delivers actually value to users and well, this change was made because it was right. The class we test is called EntityRow and not RowEntity. It is always hard to treat one value against the other.

Status: Needs review » Needs work

The last submitted patch, 61: 2457999-61.patch, failed testing.

dawehner’s picture

There we go.

alexpott’s picture

Issue tags: +Triaged core major

Discussed with @xjm, @tim.plunkett and @dawehner - we decided that this issue is a major issue which you are able to configure a view through the UI that renders unexpected results.

esolitos’s picture

I had the same issues as #59, the patch from #63 solved my issue!

Is there a reason why 'none' (an arbirtary string) was chosen over a NULL or a constant?

dawehner’s picture

@esolitos
'none' is the default value provided in \Drupal\views\Plugin\views\HandlerBase::defineOptions

vivianspencer’s picture

I can confirm, the patch from #63 also fixed an issue I was having with relationships in a view.

dawehner’s picture

@esolitos
Ha, I thought I've totally seen you online before. Cool to meet you last week. Do you think the patch looks alright?

esolitos’s picture

@dawehner
Since my team switched to Slack I always forget to open irc... It was nice to meet you as well, it's nice to put a face and a voice to the d.o usernames. :)

Back on the topic, the patch looks good and fixes the issue in all tests I did and I'm using it in production on a couple of sites w/o issues.
The only thing I still find weird is that magic 'none' string in the relationship, I'll open an issue to get the magic string into a constant, I believe it makes more sense.

ldavidsp’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update

I did not review the code but the patch in #63 fixes the problem. Do we need tests?

dawehner’s picture

The only thing I still find weird is that magic 'none' string in the relationship, I'll open an issue to get the magic string into a constant, I believe it makes more sense.

A constant is a good idea! Do you mind opening up the followup?

I did not review the code but the patch in #63 fixes the problem. Do we need tests?

This patch adds a test, but I'm not sure if provides coverage for all changes added by this patch.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 63: 2457999-63.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC, this seemed to be a random failure

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 63: 2457999-63.patch, failed testing.

jonathanshaw’s picture

Are these fails still random?

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

Yes they are

alexpott’s picture

This is an API break no? https://3v4l.org/2v5JI

dawehner’s picture

Well, we actively haven't made these entity renderers swappable ... so we can change internals.

alexpott’s picture

@dawehner fair enough - the classes involved here are all hard coded in \Drupal\views\Entity\Render\EntityTranslationRenderTrait and \Drupal\views\Plugin\views\field\Field::getEntityFieldRenderer. It is possible to swap this out at the higher level, since Drupal\views\Plugin\views\field\Field is plugin and you can alter it. But I think it is okay to consider this internal implementation to the plugin.

+++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php
@@ -90,7 +90,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
-          $relationship_handler->init($executable, $relationship);
+          $relationship_handler->init($executable, $this->displayHandler, $relationship);

This is a bug fix right? Is this never called ATM? As far as I can this is just broken in HEAD

dawehner’s picture

This is a bug fix right? Is this never called ATM? As far as I can this is just broken in HEAD

Exactly, this is what this issue is all about.

ayalon’s picture

DisplaySuite Plugin is breaking if you apply the patch.

dawehner’s picture

@ayalon
Can you explain a bit more how its breaking?

ayalon’s picture

As soon as I open a page based on Display Suite I get this error after applying the patch:

Fatal error: Declaration of Drupal\ds\Plugin\views\Entity\Render\TranslationLanguageRenderer::getLangcode(Drupal\views\ResultRow $row) must be compatible with Drupal\views\Entity\Render\EntityTranslationRendererBase::getLangcode(Drupal\views\ResultRow $row, $relationship = 'none')

ayalon’s picture

The attached patch is needed to make #63 patch compatible with Display Suite.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 84: display_suite_renderer.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Lendude’s picture

It seems DS does exactly what is being described in #77-#79, so would this be considered an API/BC break after all with examples available in contrib?

Retested the patch in #63 and its still good, so if this is still not considered an API change this can go back to RTBC I'd say.

ayalon’s picture

But still, every page that is using Display Suite will have a white screen of death if the patch I posted is not used.

james.williams’s picture

Status: Needs work » Reviewed & tested by the community

Comment 84 adds a patch for Display suite, not core. Please open a new issue with that patch, for Display Suite. This core ticket is RTBC, as of comment 76, so I'm setting it back to that.

dawehner’s picture

#84 could be added to DS before this patch landing. That sounds like an okay way.
To be honest these entity renders where meant to be purely internal.

jonathanshaw’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review
+++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
@@ -15,11 +15,13 @@
-  abstract public function getLangcode(ResultRow $row);
+  abstract public function getLangcode(ResultRow $row, $relationship = 'none');

This is pain and potentially could break BC for more than just display suite. I think we should consider a fix that does not break contrib. Maybe we could make the method not abstract and provide a default implementation. That way we can avoid the hard break. Putting back to needs review to get sub-system maintainer opinions.

alexpott’s picture

I.e do the attached patch...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs subsystem maintainer review

I'd be honestly totally happy about this particular change. In general I really like that we haven't made these renderes another plugin type as it saved us from overgenerialization.

alexpott’s picture

@ayalon any chance you can confirm that the new approach taken allows display suite to continue to work?

catch’s picture

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
@@ -28,27 +34,62 @@ public function query(QueryPluginBase $query, $relationship = NULL) {
+   * Gets the entity assosiated with a row.

associated - can be fixed on commit.

Otherwise looks great but yeah let's get confirmation that display suite is happy.

ayalon’s picture

Status: Reviewed & tested by the community » Needs work

@alexpott:
Thanks for the non breaking patch. I removed my display suite patch and reverted Display Suite to 8.2.6 version. Then I applied your latest patch. Generallyit works but there are strict warnings on every page:

Strict warning: Declaration of Drupal\ds\Plugin\views\Entity\Render\RendererBase::preRender() should be compatible with Drupal\views\Entity\Render\EntityTranslationRendererBase::preRender(array $result, $relationship = 'none') in Composer\Autoload\includeFile() (line 412 of htdocs\xx\vendor\composer\ClassLoader.php).

Strict warning: Declaration of Drupal\ds\Plugin\views\Entity\Render\TranslationLanguageRenderer::getLangcode() should be compatible with Drupal\ds\Plugin\views\Entity\Render\DefaultLanguageRenderer::getLangcode(Drupal\views\ResultRow $row, $relationship = NULL) in include() (line 11 of modules\contrib\ds\src\Plugin\views\Entity\Render\TranslationLanguageRenderer.php).

So this means that additional patching of Display Suite is necessary anyway.

jonathanshaw’s picture

So is this ds's problem to fix the warning, or does this imply something needs to be changed here?

ayalon’s picture

The issue has to be fixed here. The notice is coming from the latest patch of @alexpott. With php strict you cannot do what has been done.

dawehner’s picture

Well, there is no way to fix that properly without changing the signature IMHO. Here is a suggestion, let's fix this bug just in 8.3.x

kclarkson’s picture

So has a decision been made here about the patch and display suite?

Does anyone know if there are other modules out there besides display suite that create view content displays in views that this patch could impact?

It would be great to hear back from the maintainers from Display Suite and get this one patched As soon as possible because its a critical issue.

At this point am I supposed to just apply the patches separately?

thank

realityloop’s picture

Status: Needs work » Reviewed & tested by the community

@ayalon I'm not seeing any strict warnings with Display Suite 8.2.6 (unpatched) with Drupal core 8.2.4 using the following patches:

        "Fix views_query_views_alter() - https://www.drupal.org/node/2744069#comment-11557945": "https://www.drupal.org/files/issues/2744069-5-views-in-queries.patch",
        "Fix issue with quickedit - https://www.drupal.org/node/2661880#comment-11443453": "https://www.drupal.org/files/issues/quickedit-undefined-attr-2661880-14.patch",
        "Fix module installer - https://gist.github.com/Decipher/8a7dc379e0b7a8fc0e64ec584b309008": "https://gist.githubusercontent.com/Decipher/8a7dc379e0b7a8fc0e64ec584b309008/raw/0b7d4ea90480aef060176bb88ee49a476e0a80b0/fix_module_installer.patch",
        "Exposed date filter notice - https://www.drupal.org/node/2811887#comment-11695313": "https://www.drupal.org/files/issues/2811887-2-exposed-date-restore-type-ealier.patch",
        "Views Argument Tokens fail validation in More Link - https://www.drupal.org/node/2780891#comment-11503811": "https://www.drupal.org/files/issues/views-ignore_invalid_tokens_in_replace-2780891-6-D8.1.x.patch",
        "Cannot use relationship for rendered entity on Views - https://www.drupal.org/node/2457999#comment-11681019": "https://www.drupal.org/files/issues/2457999-93.patch"
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

@realityloop if I get ds 8.x-2.x and apply the patch to core 8.2.x and then run the Drupal\ds\Tests\BlockFieldPluginTest test I see the warnings that @ayalon is reporting. Not sure what to do here.

kekkis’s picture

My two cents: go ahead and "break" the API, the result is a warning "only" after all. This will let contrib developers fix their code quite conveniently. Essentially what @dawehner is saying in #100.

Note that at least Search API will also be affected by this change. I'm about to add an issue there much alike the one in DS.

dawehner’s picture

@alexpott
So what happens if we fix this just in the next minor release, but keep the current patch release as it is. Would that be a safe change?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rcodina’s picture

jibran’s picture

I think it is worth breaking the BC for next minor release. We can create an announcement for the change.

Lendude’s picture

Status: Needs work » Needs review

The full BC version (with thanks to @Xano for helping me wrap my head around this). Adds methods for the 'with relationship' versions and leaves the original methods intact.

Ran this against \Drupal\ds\Tests\ViewsTest and it ran without exceptions.

The #93 is an array() => [] reroll, the interdiff is against the reroll (the interdiff is hard to read I thought).

This probably needs work for at least some docblocks that need updates (and maybe some @depricated in some places), but the question is, is this preferable to a BC break?

Lendude’s picture

The last submitted patch, 110: 2457999-93-array-reroll.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 110: 2457999-109.patch, failed testing.

Lendude’s picture

This should clear up some fails.

lokapujya’s picture

+++ b/core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php
@@ -34,27 +34,55 @@ class RowEntityTest extends ViewsKernelTestBase {
+    // Ensure entities have different ids.
+    if ($entity_test->id() == $user->id()) {
+      $entity_test->delete();
+      $entity_test = EntityTest::create([
+        'user_id' => $user->id(),
+        'name' => 'test entity test',
+      ]);
+      $entity_test->save();
+    }

Is it really possible that entities could have same id?

james.williams’s picture

@lokapujya they are different entity types, so I would have thought that is quite possible, yes?

lokapujya’s picture

Yeah, I didn't notice that they were different entity types.

lokapujya’s picture

This patch fixes another problem, not sure if everyone is aware of it:

Without this patch,I created a view. Added a relationship. Then, clicked on Format->Show: Content. That brings up the "Page: How should each row in this view be styled" screen. Then, when I click "settings", nothing happens.

After this patch, the "Page: Row style options" screen will show up after clicking "settings".

dawehner’s picture

I like that.

Lendude’s picture

Discussed this direction with @dawehner at DevDays.

Made the 'byRelationship' methods so that the relationship is non-optional and made the original methods use the 'byRelationship' methods to reduce code duplication.

ayalon’s picture

Great progress! Thanks lendude for your work. #119 works for me.

dawehner’s picture

+++ b/core/modules/views/src/Plugin/views/row/EntityRow.php
@@ -166,7 +166,13 @@ public function summaryTitle() {
+      $relationship = NULL;

@@ -175,7 +181,7 @@ public function query() {
+      $this->getEntityTranslationRenderer()->preRenderByRelationship($result, isset($this->options['relationship']) ? $this->options['relationship'] : 'none');

Once its none and once NULL, this is confusing

Lendude’s picture

@dawehner would something like this be better? They are actually 2 different things. Most of EntityRow is referring to the relationship handler, but query is referring to the relationship table or alias. Hence the different defaults.

This would make the variable name in the calling function different then that used in the called function, which is not great either, but updating query() seems a little out of scope :)

jibran’s picture

FileSize
788 bytes
16.5 KB

How about this?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

+1 for $relationship_table and the simplification introduced by @jibran

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
@@ -22,6 +22,23 @@
   /**
+   * Returns the language code for the given row based on the relationship.
+   *
+   * @param \Drupal\views\ResultRow $row
+   *   The result row.
+   * @param string $relationship
+   *   The relationship to be used.
+   *
+   * @return string
+   *   A language code.
+   */
+  public function getLangcodeByRelationship(ResultRow $row, $relationship) {
+    if ($entity = $this->getEntity($row, $relationship)) {
+      return $entity->getUntranslated()->language()->getId();
+    }
+  }

As far as I can tell, this is overridden by every single child class, so I'm not sure what the value of this is.

I only stumbled on this because of the getUntranslated() call which seems very suspect to me as there is no comment there to justify it and as far as I can tell no test for this particular line either.

So I think we can either just drop this function altogether or I would prefer some justification (i.e. code comment and/or test) for this.

lokapujya’s picture

What does the relationship have to do with language? Yes, entity has to be rendered in a particular language, but what does the relationship have to do with selecting the language?

mikeker’s picture

Issue summary: View changes

Moved the steps to repro (from @ciss in #59) into the issue summary.

mikeker’s picture

Issue summary: View changes
jojonaloha’s picture

We have been using the patch in #93. After a security update we tried using the new patch in #123, but it causes fatal errors with Views Parity Row

Fatal error: Call to undefined method Drupal\views_parity_row\Plugin\views\Entity\Render\TranslationLanguageRenderer::preRenderByRelationship() in Drupal\views\Plugin\views\row\EntityRow::preRender()

The patch in #93 does not cause this problem. It seems that this might be an API change and the

preRenderByRelationship()

method either needs to be added to Drupal\views\Entity\Render\RenderBase or Drupal\views\Entity\Render\EntityTranslationRendererBase. Maybe even add a check in Drupal\views\Plugin\views\row\EntityRow::preRender() to check that function exists or that it is a subclass of the correct super class; which would mean that Views Parity Row would need to be updated.

LauraRocks’s picture

Is it okay to ask what is going on with this issue? It seems to me that the main problem is gone, or at least I could get the view to work properly but as stated here in#41 and #117, when you have a relationship for entity reference in place, you can't change the view mode that you want your content to appear, it gives an Ajax error. If you get it right the first time, no problem, but if you want to change it, you have to remove the relationship, change the view mode and put the relationship back. So it's not a major flaw, but pretty annoying...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Lendude’s picture

@tstoeckler how about this? just provide the minimum we need to? make getLangcodeByRelationship() default to getLangcode()

We can't take the method out, because that would break things when modules extend EntityTranslationRendererBase but not implement the method, right?

@jojonaloha Views Parity Row \Drupal\views_parity_row\Plugin\views\Entity\Render\TranslationLanguageRenderer should extend \Drupal\views\Entity\Render\TranslationLanguageRenderer and maybe not Drupal\views\Entity\Render\RendererBase like it currently does. That should clean things up. But don't know the reason behind that setup, so that might not work.

lokapujya’s picture

We can't take the method out, because that would break things when modules extend EntityTranslationRendererBase but not implement the method, right?

Should it be declared abstract?

LauraRocks’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Looked at this in DrupalCon Vienna with @Lauriii and this issue needs an updated issue summary. In comment #41 there is a explanation about what is still left from the original issue.

Anonymous’s picture

Issue summary: View changes
Anonymous’s picture

Status: Needs work » Reviewed & tested by the community

Updated issue summary to be a bit better. Let's not let minor stuff like that hold up fixing a major issue for site builders.

The patch works for me as well. Unless there are other major concerns with #132 it looks like a good patch.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 132: 2457999-132.patch, failed testing. View results

dagmar’s picture

Status: Needs work » Needs review
FileSize
16.45 KB
2.42 KB

Re-rolled. #132 didn't apply anymore.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Cool, that one passes.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Looks like #133 hasn't been answered yet; also maybe another review from @tstoeckler could be helpful? Thanks!

tstoeckler’s picture

+++ b/core/modules/views/src/Entity/Render/ConfigurableLanguageRenderer.php
@@ -43,4 +43,11 @@ public function getLangcode(ResultRow $row) {
+  /**
+   * {@inheritdoc}
+   */
+  public function getLangcodeByRelationship(ResultRow $row, $relationship) {
+    return $this->getLangcode($row);
+  }

+++ b/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php
@@ -16,4 +16,11 @@ public function getLangcode(ResultRow $row) {
+  /**
+   * {@inheritdoc}
+   */
+  public function getLangcodeByRelationship(ResultRow $row, $relationship) {
+    return $this->getLangcode($row);
+  }

+++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
@@ -107,6 +124,13 @@ public function getLangcode(ResultRow $row) {
+  /**
+   * {@inheritdoc}
+   */
+  public function getLangcodeByRelationship(ResultRow $row, $relationship = 'none') {
+    return $this->getLangcode($row);
+  }

As far as I can tell, these can now be removed, as they are the same as the parent implementation.

This would also alleviate #133.

(If not, I have a question: Why does TranslationLanguageRenderer have a default value for the $relationship parameter, while the others do not?)

Berdir’s picture

Status: Needs review » Needs work

Setting to needs work for that, will try to do a reroll.

Just run into this myself. It's worth pointing out that this results in a fatal error and prevents you from chosing a view mode even if you don't want to actually use a relationship, just having one on your view triggers this.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anybody’s picture

Confirming the problem still exists.

jonathanshaw’s picture

Addresses #141 which is supposed to fix #133. If the tests are green and interdiff show good implementation of #141, then someone can set to RTBC per #124 and #136.

jonathanshaw’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
jonathanshaw’s picture

Issue summary: View changes
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice simplification!

Anybody’s picture

Perfect, confirming RTBC. Can we get this into the next stable release?

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Patch looks really great now, thanks for all the effort!

Sorry, but found one more thing:

+++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
@@ -80,14 +80,22 @@ protected function getLangcodeTable(QueryPluginBase $query, $relationship) {
   public function preRender(array $result) {
+    $this->preRenderByRelationship($result, 'none');

@@ -95,9 +103,18 @@ public function preRender(array $result) {
   public function render(ResultRow $row) {
...
+    $this->renderByRelationship($row, 'none');
+  }

This can be removed now, I think, as it's identical to the parent implementation.

jonathanshaw’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
950 bytes
14.99 KB

Fixed #150

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 151: 2457999-150.patch, failed testing. View results

jonathanshaw’s picture

Issue tags: +Needs reroll

Sorry, hit limit of my git patch fu. Can't wait for the developer tooling initiative for drupal.org ...

jonathanshaw’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
14.63 KB

Encoding weirdness. Interdiff same as #150.

dawehner’s picture

@tstoeckler
Nice find!

tstoeckler’s picture

Thanks for the quick fix! RTBC++

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 154: 2457999-153.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Silly bot, saying it failed when it didn't

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 154: 2457999-153.patch, failed testing. View results

jonathanshaw’s picture

Status: Needs work » Reviewed & tested by the community
landsman’s picture

Patch 2457999-153.patch working for me, thank you @jonathanshaw !

Drupal version: 8.4.3
PHP 7.1.8

joum’s picture

Can confirm that #154 works brilliantly.

dddbbb’s picture

Patch in #154 working well for me, many thanks.

Drupal 8.4.5
PHP 7.1.11

alexpott’s picture

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
@@ -21,6 +21,21 @@
+  /**
+   * Returns the language code for the given row based on the relationship.
+   *
+   * @param \Drupal\views\ResultRow $row
+   *   The result row.
+   * @param string $relationship
+   *   The relationship to be used.
+   *
+   * @return string
+   *   A language code.
+   */
+  public function getLangcodeByRelationship(ResultRow $row, $relationship) {
+    return $this->getLangcode($row);
+  }

Maybe this is old code from an alternative fix but I don't understand why we're adding this method as getLancode() is public too. And none of the calls are from another class so even if it was protected that wouldn't matter. Ah yeah this is because we started removing stuff after #141.

Is there anything more we can trim here?

alexpott’s picture

Issue tags: +Needs change record

Also we need a change record here for the changes to \Drupal\views\Entity\Render\EntityTranslationRendererBase. It'd be great though if we could somehow come up with a way of fixing that was less disruptive.

Anybody’s picture

I can confirm the patch works perfectly with Drupal Core 8.5

Serris’s picture

patch worked for me in 8.5.1 as well

danthorne’s picture

Patch also worked for me on 8.5.1

Lendude’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs change record

CR added https://www.drupal.org/node/2959032

Went through this again, and I can't find anything more we can trim.

It'd be great though if we could somehow come up with a way of fixing that was less disruptive.

Agreed, but I think we went through quite a number of options here and this was the only way we found not to break major contrib modules.

dawehner’s picture

I gave it another review. +1 for all of it

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 164: 2457999-164.patch, failed testing. View results

Anybody’s picture

Status: Needs work » Reviewed & tested by the community

Resetting to RTBC. This seems to be a testbot mistake...
How can we ensure this important fix will be part of 8.6?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 164: 2457999-164.patch, failed testing. View results

tacituseu’s picture

Status: Needs work » Reviewed & tested by the community
zanvidmar’s picture

Patch #164 worked for me in 8.5.3. Tnx!

Anybody’s picture

Confirming RTBC again. We're using this in production since month. How can we get this into the next 8.5.x release and 8.6.x?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 164: 2457999-164.patch, failed testing. View results

tacituseu’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated failure.

AaronBauman’s picture

RTBC++

Please commit!

nevergone’s picture

Version: 8.5.x-dev » 8.6.x-dev
nevergone’s picture

#164 rerolled with 8.6.x.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 181: 2457999-181.patch, failed testing. View results

markpavlitski’s picture

Status: Needs work » Needs review
FileSize
14 KB

Rerolled against latest 8.6.x HEAD.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community
Anybody’s picture

Version: 8.6.x-dev » 8.7.x-dev
Anybody’s picture

Confirming RTBC for #183. Works perfectly on 8.6.x and 8.7.x

dagmar’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure about some side effects of this:

+  /**
+   * Gets the entity associated with a row.
+   *
+   * @param \Drupal\views\ResultRow $row
+   *   The result row.
+   * @param string $relationship
+   *   (optional) The relationship.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface|null
+   *   The entity might be optional, because the relationship entity might not
+   *   always exist.
+   */
+  protected function getEntity($row, $relationship = 'none') {
+    if ($relationship === 'none') {
+      return $row->_entity;
+    }
+    elseif (isset($row->_relationship_entities[$relationship])) {
+      return $row->_relationship_entities[$relationship];
+    }
+    return NULL;
+   */

If there is a relationship defined in the parameter, but is not defined in the $row, it returns NULL.

Then. This value is used by renderByRelationship. That says it always returns an array. Which is not true based on the code of the method.

+  /**
+   * Renders entity data.
+   *
+   * @param \Drupal\views\ResultRow $row
+   *   A single row of the query result.
+   * @param string $relationship
+   *   The relationship to be used.
+   *
+   * @return array
+   *   A renderable array for the entity data contained in the result row.
+   */
+  public function renderByRelationship(ResultRow $row, $relationship) {
+    if ($entity = $this->getEntity($row, $relationship)) {
+      $entity_id = $entity->id();
+      return $this->build[$entity_id];
+    }
+  }

So either:

  1. We need tests to check what happens here.
  2. Or, we need to refactor that method to always return an array, since it is what render() was doing.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Berdir’s picture

Status: Needs work » Needs review
FileSize
13.98 KB

Just a reroll for 8.7.x for now.

swilmes’s picture

Just to add, I was able to apply the 8.6 patch in #183 but afterwards I can't open the "Query Settings" modal. Error is " Invalid arguments passed in /var/www/docroot/core/modules/views/src/Plugin/views/query/Sql.php on line 320".

Edit: The error I'm getting is because $this->options['query_tags'] = NULL and obviously the implode command won't work. I can fix it with a check on the value first, but I'm not sure what in the patch would be changing this. I may have a separate issue altogether. I am using contextual filters or as well, so it could be something there.

jordan.jamous’s picture

#189 worked for 8.7.x. Thank you.

jonathanshaw’s picture

Status: Needs review » Needs work

NW for #187

Anonymous’s picture

Our site breaks horribly in 8.7 without the patch in #189. How'd this make it through?

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\views\Entity\Render\TranslationLanguageRenderer::preRenderByRelationship() in Drupal\views\Plugin\views\row\EntityRow->preRender() (line 251 of core/modules/views/src/Plugin/views/row/EntityRow.php).

This is when visiting a page with a view that has referenced nodes displayed.

Lendude’s picture

Status: Needs work » Needs review
FileSize
438 bytes
13.99 KB

Re: #190
I can open the query settings without problem on a vanilla umami install. If this is really related to the patch we need some steps to reproduce that.

Re: #193

Our site breaks horribly in 8.7 without the patch in #189. How'd this make it through?

Make it through what? TranslationLanguageRenderer::preRenderByRelationship() doesn't exist without this patch, nor are there be any calls to it without this patch. Seems more likely it was using this patch pre-8.7 also.

This addresses #187

dagmar’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed this patch again and indeed achieves my concerns of #187.

Anybody’s picture

Confirming RTBC! Thank you all, nice to have this fixed in core soon.

Anonymous’s picture

You're right, pre-8.7 we were using this patch :)

8.7 broke the patch, looks fixed now.

grantkruger’s picture

#194 worked for me for 8.7.1. My thanks to Lendude and others who keep rerolling this patch all these years. As a stand-alone part time Drupal site maintainer your efforts are incredibly helpful to me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 194: 2457999-194.patch, failed testing. View results

dagmar’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 194: 2457999-194.patch, failed testing. View results

jonathanshaw’s picture

Status: Needs work » Reviewed & tested by the community
badrange’s picture

This has been RTBC for 2 months. What is it that holds it back from being committed?

xjm’s picture

@badrange, many committers are partly or entirely volunteers, and all are humans who sometimes take vacations. :) Three committers are on vacation this month.

All issues marked RTBC will be addressed at some point (whether with a commit or a further comment asking for further discussion/changes).

badrange’s picture

Thanks for getting back to me xjm! I asked because I have some spare time just this week and wanted to know if there was anything I could do to push this further, like adding some issue tags to ensure that the right person spots it at the right time or similar.

I wish every single core committer a long and lovely vacation!

plach’s picture

Manually/tested and reviewed #194 and it works great, thanks to everyone working here for the thorough reviews and testing!

I agree with @alexpott that ideally we would not introduce changes in signatures of public method not marked as @internal, however all the renderer code is pretty self contained and hard to exploit outside its very limited (and hard-coded) use case, so I believe it's unlikely that we have any codebase out there extending any of the affected classes (or using the trait directly). Changes are preserving BC for callers, so I think it should be safe enough to commit this. I think a way to mitigate Alex's concerns could be to commit this only to 8.8.x initially and check whether any breakage is reported. We can leave the issue RTBC for 8.7.x and backport it once/if it's deemed safe enough.

plach’s picture

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
@@ -62,11 +62,13 @@ protected function getEntityTranslationRenderer() {
+   * @param string $relationship
+   *   The relationship to be used, or 'none' by default.
...
-  public function getEntityTranslation(EntityInterface $entity, ResultRow $row) {
+  public function getEntityTranslation(EntityInterface $entity, ResultRow $row, $relationship = 'none') {

On a second thought, would it be feasible to add a ::getEntityTranslationByRelationship() method and leave this signature untouched?

devkinetic’s picture

@plach +1 on that solution.

plach’s picture

Status: Reviewed & tested by the community » Needs review
Patrick Ryan’s picture

+1 so far so good on both #194 and #207

baisong’s picture

Running into this issue too, on 8.7.7, and both #189 and #194 fail to apply

Jon Pollard’s picture

Also 8.7.8, patch won't apply

PFEnriquez’s picture

In the meantime you can use the solution posted on #79

  1. Make the change
  2. Change the view mode
  3. Rollback the change

It is only a temporary solution until someone reroll the patch.

sathish.redcrackle’s picture

I tested the patch with 8.7.7, 8.7.8 versions and i dint found any errors.

Tested on new instance

Patch success

Working correctly

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Lendude’s picture

jibran’s picture

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
@@ -62,13 +62,11 @@
-  public function getEntityTranslation(EntityInterface $entity, ResultRow $row, $relationship = 'none') {
+  public function getEntityTranslation(EntityInterface $entity, ResultRow $row) {

Do we need some kind of @todo to make sure this method gets removed and not be used anymore?

Lendude’s picture

@jibran yeah, maybe. But in an ideal world, we would:

  • deprecate getEntityTranslation here, remove it in D9
  • rename getEntityTranslationByRelationship to getEntityTranslation and deprecate getEntityTranslationByRelationship in D10
  • remove getEntityTranslationByRelationship in D11.

And since we can't deprecate stuff in D8 anymore, it's really D(x + 1).....

Or we can just leave them both in.... ¯\_(ツ)_/¯

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, I'd rather commit #194 instead. It has the correct BC, imo but anyway #207 is addressed so back to RTBC.

plach’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests coverage
FileSize
430.42 KB
1.11 MB

I was hoping to commit this, unfortunately more review/testing revealed that the latest patch does not take multilingual + relationships into account in one specific case:

+++ b/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php
@@ -79,6 +79,32 @@ public function getEntityTranslation(EntityInterface $entity, ResultRow $row) {
+  public function getEntityTranslationByRelationship(EntityInterface $entity, ResultRow $row, $relationship = 'none') {
+    // We assume the same language should be used for all entity fields
+    // belonging to a single row, even if they are attached to different entity
+    // types. Below we apply language fallback to ensure a valid value is always
+    // picked.
+    $translation = $entity;
+    if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) {
+      $langcode = $this->getEntityTranslationRenderer()->getLangcode($row);
+      $translation = $this->getEntityRepository()->getTranslationFromContext($entity, $langcode);
+    }
+    return $translation;

I realized that the $relationship parameter is not actually used in the method body. We need also an EntityTranslationRendererBase::getLangcodeByParameter() method so that the new ::getEntity() method can be invoked in DefaultLanguageRenderer::getLangcode() with the proper $relationship info. If we don't do so, when dealing with a relationship, the default language of the base entity instead of the referred entity will be returned, which would lead to unexpected results as soon as the two entities have different default languages. I'm attaching a DB dump of the local test site I used to confirm this. The view there can be used to add test coverage for this.

EntityTranslationRendererBase::getLangcode() and EntityTranslationRendererBase::getEntityTranslation() should become thin wrappers around the new corresponding EntityTranslationRendererBase::getLangcodeByRelationship() and EntityTranslationRendererBase::getEntityTranslationByRelationship() methods and would hardcode the 'none' relationship, as, for instance, EntityTranslationRendererBase::preRender() is doing.

Unfortunately EntityTranslationRendererBase::getLangcode() is currently an abstract method, which means that EntityTranslationRendererBase::getLangcodeByRelationship() needs to be abstract as well. However this should be akin to adding new methods to interfaces and thus allowed by our BC policy, I'll check with a release manager.

We will need to update all invocations of EntityTranslationRendererBase::getLangcode() and EntityTranslationRendererBase::getEntityTranslation() to use the new methods instead.

plach’s picture

I just confirmed with @catch that the approach I suggested is acceptable from a RM perspective, if the logic is correct.

Lendude’s picture

Status: Needs work » Needs review
FileSize
14.56 KB

Just a reroll for #3087692: Remove the core key from views configuration. for now, looking into the rest. 'Needs review' to run the testbot, but still needs work.

Lendude’s picture

@plach going back down the rabbit hole here.....doing #220 would essentially move us back to the patch in #123. Except there we added getLangcodeByRelationship as a non-abstract method to provide BC. But then we stripped everything off again to make this more lean.

The reason we went through all the trouble of not having a BC breaking patch (even if it was strictly allowed by the guidelines) is that we have known BC breaks in both Display Suite and Search API, two pretty major modules (30k and 50k D8 installs). So I'd really be in favour of not breaking BC here.

Ok, so this adds getLangcodeByRelationship back in, but now correctly, since I now see what happend in #125 (better late then never I guess), but in a BC respecting way, so a silly stub method on EntityTranslationRendererBase to make sure nothing breaks.

This fixes the fail in #220, but trying to wrap my head around how to get a test in the proper state to test this.

Status: Needs review » Needs work

The last submitted patch, 223: 2457999-223.patch, failed testing. View results

plach’s picture

@Lendude:

The patch looks very good now, thanks!

However, there are a few more invocations of EntityTranslationRenderTrait::getEntityTranslation() that need to be updated to use ::getEntityTranslationByRelationship(), e.g. \Drupal\views\Plugin\views\field\RenderedEntity.

This fixes the fail in #220, but trying to wrap my head around how to get a test in the proper state to test this.

You should find the test view I used to manually test this in the DB dump at #220, along with some test content and the required configuration. Converting that into a test should be enough. Alternatively RowEntityRenderersTest could be a good starting point.

steveoriol’s picture

Fail to apply the patch #223 or #222 on D8.7.8 ou D8.7.9 via composer.json
but patch from #216 : 2457999-215.patch works...

rcodina’s picture

Patch #223 applies correctly on 8.8.1 via composer.

Ludo.R’s picture

Same here: Patch #223 applies correctly on 8.8.1 via composer and works fine, thanks!

xjm’s picture

Issue tags: -needs tests coverage +Needs tests
brandonratz’s picture

Patch #223 applies clean on 8.8.5. Fixes a AJAX error on the view mode selection when a relationship is present.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

narendra.rajwar27’s picture

Assigned: Unassigned » narendra.rajwar27
narendra.rajwar27’s picture

Status: Needs work » Needs review
FileSize
16.04 KB

patch applied in drupal 9.1.x-dev version to make relationship for rendered entity on Views working.

jonathanshaw’s picture

Assigned: narendra.rajwar27 » Unassigned

Thanks!

jonathanshaw’s picture

Status: Needs review » Needs work

NW for #225

Berdir’s picture

Just a reroll for 8.9.x for those who need it.

i-trokhanenko’s picture

The #236 patch works well for me, thanks @Berdir
+1 RTBC

sharma.amitt16’s picture

Status: Needs review » Needs work
FileSize
230.72 KB

I can confirm that issue persists in D9.1.x branch also. I tested this as per steps to reproduce given in IS. After clicking on the teaser nothing happens.

But the patch #236 is not applying on D9.1.x getting error

~/Sites/drupal-9.0.0-beta2(9.1.x*) » curl https://www.drupal.org/files/issues/2020-05-30/cannot-use-relationship-2457999-236.patch | git apply -v                                  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16539  100 16539    0     0  11359      0  0:00:01  0:00:01 --:--:-- 11382
Checking patch core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php...
Checking patch core/modules/views/src/Entity/Render/EntityFieldRenderer.php...
Hunk #1 succeeded at 218 (offset -20 lines).
Checking patch core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php...
Checking patch core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php...
Checking patch core/modules/views/src/Entity/Render/RendererBase.php...
Checking patch core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php...
Checking patch core/modules/views/src/Plugin/views/row/EntityRow.php...
Hunk #1 succeeded at 209 (offset -26 lines).
Hunk #2 succeeded at 222 (offset -26 lines).
Hunk #3 succeeded at 230 (offset -26 lines).
Checking patch core/modules/views/src/Plugin/views/row/RowPluginBase.php...
Checking patch core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_row.yml...
Checking patch core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php...
error: while searching for:
   * @var array
   */
  public static $modules = [
    'taxonomy',
    'text',
    'filter',
    'field',
    'system',
    'node',
    'user',
  ];


error: patch failed: core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php:22
error: core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php: patch does not apply
-------------------------------------------------------------------------------------------------------------------------------

But patch applied successfully with 8.9.x branch as given in previous comments as well. Also, it fixed the problem in 8.9. It works fine.

After patch apply

Berdir’s picture

Yes, as I wrote, #236 is specifically a reroll for 8.9, the previous patch is for 9.1 Needs work is correct though for tests.

sharma.amitt16’s picture

Status: Needs work » Needs review

Oh, I missed that. Apologies, checking patch #233.
Removing the reroll tag and changing the status.

sharma.amitt16’s picture

Tested #233. Working fine with 9.1.x as well.

After patch apply 9.1

+1 for RTBC

Anybody’s picture

Status: Needs review » Needs work

Setting this back to Needs work as of #239 (tests) and #225 (more invocations of EntityTranslationRenderTrait::getEntityTranslation()) while I can confirm that the patches work perfectly for me in our projects.

Thanks a lot!

lzimmerman_jr’s picture

#223 is failing for 8.8.8 today; I think we'll need a reroll for this version.

lzimmerman_jr’s picture

Testing an updated patch for 8.8.x based on #223, I believe the only change causing failure was an array change for coding standards, from 8.8.7.
(File core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php)

This slight update applies cleanly for me.

bkosborne’s picture

The patch in #236 worked fine for me on 8.8.8

lzimmerman_jr’s picture

Retested and that one works for me also on 8.8.8!

Peacog’s picture

Status: Needs work » Needs review
FileSize
16.16 KB

Re-roll needed for 9.1.x due to some changes in core/modules/views/tests/src/Kernel/Plugin/RowEntityTest.php

Status: Needs review » Needs work

The last submitted patch, 247: cannot-use-relationship-2457999-247.patch, failed testing. View results

Peacog’s picture

Status: Needs work » Needs review
FileSize
16.17 KB

A better re-roll...

chucksimply’s picture

#236 works for me on 8.9.1

eblue’s picture

#236 works for me on 8.9.1 as well.

othermachines’s picture

#236 resolves the issue for me on 8.9.1. Thanks!

en-cc-org’s picture

#236 was working for us on 8.9.1 but patch fails to apply when updating to 8.9.6
We use https://github.com/cweagans/composer-patches and all other (module) patches re-applied as expected. Just checking to see if others are experiencing.

Installing drupal/core (8.9.6): Downloading (100%)
Extracting archive - Applying patches for drupal/core
https://www.drupal.org/files/issues/2020-05-30/cannot-use-relationship-2... (Issue #2457999: Cannot use relationship for rendered entity on Views)
patch '-p1' --no-backup-if-mismatch -d 'web/core' < '/tmp/5f6a6b79951a3.patch'
sh: patch: command not found
patch '-p0' --no-backup-if-mismatch -d 'web/core' < '/tmp/5f6a6b79951a3.patch'
sh: patch: command not found
patch '-p2' --no-backup-if-mismatch -d 'web/core' < '/tmp/5f6a6b79951a3.patch'
sh: patch: command not found
patch '-p4' --no-backup-if-mismatch -d 'web/core' < '/tmp/5f6a6b79951a3.patch'
sh: patch: command not found
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-05-30/cannot-use-relationship-2...

othermachines’s picture

Hi @en-cc-org - We updated to 8.9.6 with no issues with this patch. We are also using cweagans/composer-patches. The patch itself is the same. The "command not found" output tells me you have some other issue.

en-cc-org’s picture

Thank you - after many more hours, think the issue is Pantheon's Terminus Composer plugin: https://github.com/pantheon-systems/terminus-composer-plugin/issues/7 reported by another user in May.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Dippers’s picture

The patch in #236 appears to break the 'Alternating View Mode' feature of the 'Display suite: content' row plugin. It causes that plugin to ignore the specified view modes and just use the default view mode.

The problem is that DS extends EntityRow and EntityTranslationRenderedBase to implement it's own renderer. This overrides EntityTranslationRenderedBase>preRender() to execute its renderer but it does not override EntityRow->preRender(). This means the original EntityRow->preRender() is run which now calls EntityTranslationRenderedBase->preRenderByRelationship() and since this does not exist in the extended DS class the DS renderer is bypassed.

The fix would seem to be to extend EntityTranslationRenderedBase->preRender() rather than introduce the new methods.

phjou’s picture

#249 seems to be working. 236 is not applying anymore on D9

Berdir’s picture

phjou’s picture

@Berdir: Thanks for the reroll, works good

Anybody’s picture

Status: Needs review » Needs work

I can confirm #236 to be working perfectly for Drupal 8.9 without any problems for month and reroll #259 for Drupal 9.1. Issue raised in #257 by @Dippers should be created as follow-up issue in DS, I guess? Would you like to do this already @Dippers?

So RTBC is +1, but tests are still missing as of @Berdir's comment in #239 (tests) as @Berdir commented #259 to be "just" a reroll. So setting this back to needs work for Tests.

nattyweb’s picture

#236 resolved the problem for me with D8.9.13. Many thanks - only just come across this problem.

Artusamak’s picture

I confirm that #259 fixes the issue on 9.1.x (9.1.3 in my situation).

Thank you for the patch.

ccjjmartin’s picture

Confirmed functional on #259. Running Drupal 9.1.3.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

super_romeo’s picture

I confirm that #259 fixes the issue on 9.1.x (9.1.8 in my situation).

donquixote’s picture

Ron Collins’s picture

The patch for 9.2 in comment #267 worked for me.

rcodina’s picture

The patch for 9.2.x in #267 worked for me too. Thanks!

rcodina’s picture

Status: Needs work » Needs review
patrick.thurmond@gmail.com’s picture

I had to use the 8.9.x #267 patch today. Works great. Why is this not merged yet?

dagmar’s picture

Status: Needs review » Needs work

Why is this not merged yet?

Because this feature need Tests.

rcodina’s picture

It has been 6 years so far since this issue was created. Still today, a feature available on Drupal 7 is not yet ready for D8 and D9. Could anyone add tests please?

dagmar’s picture

Reading the entire thread in addition to tests it seems the comment mentioned here #2457999-225: Cannot use relationship for rendered entity on Views needs to be addressed as well

joelsteidl’s picture

The patch for 9.2 in comment #267 worked for me.

danflanagan8’s picture

Status: Needs work » Needs review
FileSize
1000 bytes

I want to help write the missing tests here. Here's a patch that triggers the error mentioned in the IS. What other test cases are missing?

Status: Needs review » Needs work

The last submitted patch, 276: 9.3.x-2457999-276-FAIL.patch, failed testing. View results

jonathanshaw’s picture

Looks like we're still missing a fix for the original bug :)

Additional tests needed are discussed in #225.

danflanagan8’s picture

Looks like we're still missing a fix for the original bug :)

The patch for 9.3.x in #267 does fix the failing test I posted in #276. I just didn't post a combined patch because without the other missing tests it's not especially useful.

danflanagan8’s picture

FileSize
118.76 KB

@plach,
I do not understand the relevance of the View referenced in comment #220. I just spun up a D8.9.x site with the db dump and this is what I see for that View, no patch applied.

This View doesn't show Content, it shows Fields. And I haven't applied any patches for this issue that would have possibly caused this language bug as a regression. There may be a bug here, but I don't see how it's related to the issue at hand. Does the IS need a major update? Has the scope increased significantly?

I want to help get this committed but I just don't understand what kind of tests we're looking for.

danflanagan8’s picture

Status: Needs work » Needs review
FileSize
15.58 KB
31.73 KB
16.15 KB

After reading through #2313159: [meta] Make multilingual views work and #2446681: Error "Column 'langcode' in field list is ambiguous" thrown due to TranslationLanguageRenderer not rendering a field from a relationship a bit, it looks like this is has become the de facto issue for fixing how Views handles finding the correct translation for a relationship. The IS should probably be updated here to make that goal clear. In the meantime, here are the long-awaited tests for multilingual relationships with either the Field row or Entity row, as well as the test that exposes the UI bug detailed in the IS.

I'll post the patch from #267 to run against the new fail tests as well. The interdiff attached is equivalent to the 9.3.x patch from #267.

danflanagan8’s picture

oops. Let's try again without the extra whitespace.

Update to highlight test failures:

First failure was the bug described in the IS:

1) Drupal\Tests\views\Functional\Handler\HandlerTest::testRelationshipUI
Exception: TypeError: Drupal\views\Plugin\views\relationship\RelationshipPluginBase::init(): Argument #2 ($display) must be of type Drupal\views\Plugin\views\display\DisplayPluginBase, array given, called in /var/www/html/core/modules/views/src/Plugin/views/row/RowPluginBase.php on line 93
Drupal\views\Plugin\views\relationship\RelationshipPluginBase->init()() (Line: 64)

Third failure was the bug pointed out in #220 related to incorrect handling of "Original language of content in view row" (***LANGUAGE_entity_default***) when using relationships:

2) Drupal\Tests\views\Kernel\Entity\RowEntityRenderersTest::testFieldRenderersRelationship
The default language renderer behaves as expected.
Failed asserting that false is true.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php:388
/var/www/html/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php:309
/var/www/html/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php:178
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:722

The second failure is related to the Entity row plugin, but I don't know if it has specifically been discussed anywhere. I don't have anything special to say about it.

The last submitted patch, 282: 2457999-282-FAIL.patch, failed testing. View results

danflanagan8’s picture

And perhaps as the final touch (maybe?), let's address the remaining concern from #225 related to getEntityTranslationByRelationship().

danflanagan8’s picture

Issue tags: -Needs tests
Javier_Rey’s picture

Comment #257 is right, applying this patch breaks the functionality of the "Alternating View Mode" display suite module. I have tried to modify both the module and the core but I can't get it to work, any alternative solution?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alvarito75’s picture

Confirming patch #284 working well in core 9.3.7 for me after upgrading from Drupal 8.9 and applying this patch.

tonytheferg’s picture

282 worked for me. For some reason 284 would not apply. I do have some other views patches though. :\

SocialNicheGuru’s picture

#284 worked for me.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alayham’s picture

Status: Needs review » Reviewed & tested by the community

#284 Works for me on 9.5.x-dev

alexpott’s picture

Over the years our standards have changed for typehints etc... so I'm updating the patch with the latest standards for 10.x and 9.x....

For me the 1 remaining question is should we be deprecating \Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslation() here - I'm not sure.

alexpott’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Needs work

Discussed with @Lendude. We agreed that this should be 10.1.x because it has cuase contrib breaks in the past so this is too late for 9.5.x/10.0.x. Given that we should deprecate \Drupal\views\Entity\Render\EntityTranslationRenderTrait::getEntityTranslation() in favour of \Drupal\views\Entity\Render\EntityTranslationRenderTrait:: getEntityTranslationByRelationship() - we'll need another change record for this specific change. Given the change is to:

   public function getEntityTranslation(EntityInterface $entity, ResultRow $row) {
    return $this->getEntityTranslationByRelationship($entity, $row);
  }

I don't think we need specific test coverage of the new deprecation message - unless adding a test is super simple.

Lendude’s picture

Second CR https://www.drupal.org/node/3311862 for the deprecation, I'll roll a patch to use it

Lendude’s picture

Status: Needs work » Needs review
FileSize
1.17 KB
37.79 KB

Deprecation added.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Novice

The test fail is simply that the deprecation message added in #296 should read "removed from" not removed in", I've tagged this for a novice fix.

I'm setting to RTBC anyway as that best describes the state of the issue at this point, apologies if that's a misjudgment.

Lendude’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 298: 2457999-298.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Needs review
FileSize
467 bytes
38.38 KB

Deprecated function was still used in core, could only find one occurrence still, lets see if that fixes it.

jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Nice

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed eb019c1 and pushed to 10.1.x. Thanks!

I tried to get the credit right - if I've made a mistake please let me know.

  • alexpott committed eb019c1 on 10.1.x
    Issue #2457999 by Lendude, danflanagan8, dawehner, donquixote, alexpott...
Petr Illek’s picture

Would this be merged into 9.x as well?

longwave’s picture

@Petr Illek please see #294 - you might be able to use the patch from #293 against 9.5.x, but it will not be present in a released version until 10.1.0.

andres.torres’s picture

Thank you all for the hard work here! this is so very helpful!!

Status: Fixed » Closed (fixed)

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

Anybody’s picture

https://git.drupalcode.org/project/drupal/commit/eb019c1.diff (which was committed in #303 indeed works against 9.5.x - thanks! :)

david.muffley’s picture

FileSize
37.03 KB

While this is closed and committed to 10.1.x, #308 and #293 no longer apply to 9.5.1 due to surrounding changes.
Here's a re-rolled patch for those of us who still need it for 9.5.x.

grantkruger’s picture

#309 worked for me on 9.5.2. Thank you david.muffley!

nicklundy’s picture

#309 also worked for me on 9.5.2. Thank you!!

super_romeo’s picture

Is there any patch for D10.0?

liquidcms’s picture

confirming that #309 works on D9.5.8, the earlier patches did not.

doxigo’s picture

Also confirming that #309 works on Drupal 9.5.8, this needs to be committed to 9.x as well

ChrisSnyder’s picture

Is this still an issue for Drupal 10.0?

Lendude’s picture

See #302, committed to 10.1, so anything earlier will not have this fix

Lendude’s picture

See #302, committed to 10.1, so anything earlier will not have this fix

joegraduate’s picture

FileSize
37.02 KB

Re-rolled patch #309 for 10.0.x.

32i’s picture

#284 worked for 9.4.x

LRoels’s picture

I traced issues of a DS ticket back to changes in this ticket.
The issue in question is this one: https://www.drupal.org/project/ds/issues/3394419

Anyone that could take a look to see what the issue could be?