The public cloneView() method is some of the ugliest code I've ever written, and I'd like it to be removed forever :)

Its entire existence comes from a block of code with comments indicating it was to work around PHP 4.4.7's object handling.

Patch coming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
6.63 KB

I tested this manually, and since it drives the entire functionality of attachments and feeds, it already has coverage.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Issue tags: +VDC

No wonder no one reviewed this :)

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.phpundefined
@@ -244,7 +244,7 @@ public function submitOptionsForm(&$form, &$form_state) {
+  public function attachTo(ViewExecutable $clone, $display_id) {

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -1464,7 +1464,9 @@ public function attachDisplays() {
+        $cloned_view = new static($this->storage);

So we have to decide whether it is a ViewExecutable or a storage, but couldn't be both at the same time :) I will write some tests now, just to be sure it will not be broken.

+++ b/core/modules/views/views.moduleundefined
@@ -1418,21 +1413,12 @@ function views_get_applicable_views($type) {
+    foreach ($executable->displayHandlers as $id => $handler) {
+      if (!empty($handler->definition[$type]) && $handler->isEnabled()) {
+        $result[] = array($executable, $id);
       }

The main advantage not checking the definition of the plugin here is, that all views displays (even the ones which come from a view without a page), though i'm not sure we have to care that much, as things will change a lot in the future anyway.

+++ b/core/modules/views/views_ui/admin.incundefined
@@ -1460,8 +1460,7 @@ function views_ui_config_item_form($form, &$form_state) {
-          $temp_view = $view->cloneView();
-          views_ui_cache_set($temp_view);
+          views_ui_cache_set($view);

Wasn't the point of cloning the view here to not contain all the runtime information of the executable. views_ui_cache_set already removes some of the values, but i guess there might be values left?

dawehner’s picture

FileSize
6.67 KB
823 bytes

Tim explained me how that static() works so here comes a small doc improvement.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The tests are added in #1861852: Change notice: Views Attachments aren't rendered anymore so this issues seems to be fine. (not sure whether we want to RTBC/commit a patch which contains parts which are known to be broken)

tim.plunkett’s picture

This has test coverage from Feeds tests, which are another form of attachment, and they work.
And this doesn't further break Attachment displays AFAIK.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice to get rid of this smelly PHP4 code. :) Great job!

Committed and pushed to 8.x. Thanks!

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