Follow up for #1446382-27: Need a reliable way to determine if a specific bundle for an entity type is translatable through #33

Problem/Motivation

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -985,6 +985,13 @@ public function getOriginalEntity() {
+    return $this->__call(__FUNCTION__, func_get_args());

looks like confusing, possibly infinite looping magic.

But it's a common pattern, in many existing methods in that class.

It pass the call through to __call() which forwards any method call to $this->storage.

Proposed resolution

Instead of just documenting though, change it to call $this->storage directly instead of doing that indirection which just slows things down.

The same way that EntityBCDecorator does it, which means simply $this->storage->isTranslatable() in this case or $this->storage->setNewRevision($value) for an example with arguments. The additional human-overhead of doing this once is not big but it helps both with performance and it's better to understand.

Remaining tasks

  • make this issue summary accurate

User interface changes

No UI changes.

API changes

No API changes.

Original report by @xjm, @Berdir, @tim.plunkett

in #1446382-27: Need a reliable way to determine if a specific bundle for an entity type is translatable through #33

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm’s picture

Priority: Minor » Normal
Issue tags: +Needs issue summary update, +VDC
xjm’s picture

Component: entity system » views_ui.module
damiankloip’s picture

Status: Active » Needs review
FileSize
10.46 KB
Berdir’s picture

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -733,296 +734,289 @@ public function getFormProgress() {
   /**
-   * Passes through all unknown calls onto the storage object.
-   */
-  public function __call($method, $args) {
-    return call_user_func_array(array($this->storage, $method), $args);

If we also want to support calls to the storage that is not defined in the interface, then we could keep it, just not use it for the explicitly defined methods. I don't know if there are any such calls, I guess the testbot will tell us?

damiankloip’s picture

Yeah, testbot can tell us. Sure thought, if you want I can just add that back in. Or do you want to wait to see if we actually need it? Maybe it does make sense to have it anyway, not sure.

Status: Needs review » Needs work

The last submitted patch, 1945348.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
0 bytes

epic fail there.

damiankloip’s picture

FileSize
10.45 KB

Bah..

Status: Needs review » Needs work

The last submitted patch, 1945348-8.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
10.25 KB

ok, maybe __call needs to stay.

Status: Needs review » Needs work
Issue tags: -Needs issue summary update, -API clean-up, -VDC

The last submitted patch, 1945348-10.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: +Needs issue summary update, +API clean-up, +VDC

#10: 1945348-10.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice!

xjm’s picture

Title: change __call(__FUNCTION__ strangeness to direct calls » Call decorated storage methods in ViewsUI explicitly

Is this title accurate? I am parroting @dawehner. :D

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Gosh, that's much nicer!

Committed and pushed to 8.x. Thanks!

olli’s picture

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php
@@ -743,286 +744,286 @@ public function __call($method, $args) {
   public function isTranslatable() {
-    return $this->__call(__FUNCTION__, func_get_args());
+    return $this->isTranslatable();
   }

#1962130: Fatal Error: ViewUI::isTranslatable endless loop

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