Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pminf created an issue. See original summary.

pminf’s picture

Issue summary: View changes
pminf’s picture

Issue summary: View changes
pminf’s picture

It turns out, that the response which is returned by the BareHtmlPageRenderer is used to create another response. The last step is wrong and should be removed.

pminf’s picture

FileSize
157.77 KB
pminf’s picture

Issue summary: View changes
nikunjkotecha’s picture

Status: Needs review » Reviewed & tested by the community

Verified the fix, thanks for the patch @pminf.

samuel.mortenson’s picture

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

Thanks for the patch @pminf! I'm glad the status code information is gone, but it still feels awkward to see the "Labels" text flash before closing the modal/iframe. This patch removes the "Labels: ..." text as well, which as far as I know is only there for debugging anyway. Only uploading one patch since it applies to both branches.

Status: Needs review » Needs work

The last submitted patch, 8: entity-browser-8.x-1.x-iframe-selection-response-2944758-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

samuel.mortenson’s picture

Issue tags: +Nashville2018, +D8Media
mmbk’s picture

Assigned: pminf » Unassigned
Status: Needs work » Closed (outdated)

Meanwhile the 8.x-1.x-dev branch is not showing this behavior any more.

Patch #4 was implemented in https://www.drupal.org/project/entity_browser/issues/2969163, by injecting the renderer . That patch was applied to both branches

So I consider this issue obsolete.

askibinski’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Closed (outdated) » Needs review
FileSize
1.86 KB

The fix in #2969163: Remove deprecated drupal_render was about dependency injection but still uses a new response object, and the markup is left untouched in that issue.

I'm still seeing the cache headers being output in 2.x, so here is a reroll for 2.x.

Status: Needs review » Needs work

The last submitted patch, 12: 2944758-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

Issue summary: View changes
FileSize
157.6 KB

I just encountered this bug on a site using 8.x-2.1, and upon updating the code to the dev version, it didn't go away.

extra output at top of response

oknate’s picture

Switching to the latest dev branch (at commit hash 7dc41e0a93c89bd4dbc969fcd62f0619df3e3b92 ) unfortunately didn't fix the issue for me, so it's not fixed yet.

oknate’s picture

FileSize
150.37 KB

Patch 12 works, the response doesn't have the status:
patch 12

oknate’s picture

Status: Needs work » Needs review
FileSize
5.53 KB
3.66 KB

Working on fixing the tests.

For EntityBrowserViewsWidgetTest.php, the fix means that when you submit the form (when not in an iframe), it now returns an a blank page with the javascript to propagate the selection. But we can test the javascript returned:

@@ -63,13 +63,21 @@ class EntityBrowserViewsWidgetTest extends EntityBrowserWebDriverTestBase {
+   $script = "return drupalSettings.entity_browser.iframe.entities[0];";
+    $result = $this->getSession()
+      ->getDriver()
+      ->getWebDriverSession()
+      ->execute([
+        'script' => $script,
+        'args' => [],
+      ]);
+    $this->assertEquals($file->id(), $result[0]);
+    $this->assertEquals('file', $result[2]);

This tests drupalSettings in Iframe::propagateSelection:

 public function propagateSelection(FilterResponseEvent $event) {
    $render = [
      '#attached' => [
        'library' => ['entity_browser/' . $this->pluginDefinition['id'] . '_selection'],
        'drupalSettings' => [
          'entity_browser' => [
            $this->pluginDefinition['id'] => [
              'entities' => array_map(function (EntityInterface $item) {
                return [$item->id(), $item->uuid(), $item->getEntityTypeId()];
              }, $this->entities),
              'uuid' => $this->request->query->get('uuid'),
            ],
          ],
        ],
      ],
    ];

    $event->setResponse($this->bareHtmlPageRenderer->renderBarePage($render, $this->t('Entity browser'), 'page'));
  }

For ImageFieldTest.php, I just needed to add some waiting.

oknate’s picture

Here's a test only patch, that should fail, as well as an updated patch that includes test coverage for the bug:

    $this->assertSession()->responseNotContains('HTTP/1.0 200 OK');
    $this->assertSession()->responseNotContains('Cache-Control: no-cache, private');
oknate’s picture

The last submitted patch, 18: entity-browser-no-visible-response-status-2944758-18--TEST-ONLY.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

oknate’s picture

Status: Needs review » Reviewed & tested by the community

I'm going to mark this RTBC, based on #7, #8, #12 and my own testing. My patch just fixed the tests and added test coverage.

  • oknate committed 52b48b1 on 8.x-2.x
    Issue #2944758 by oknate, pminf, samuel.mortenson, askibinski: Iframe...

  • oknate committed 5f8c43f on 8.x-1.x
    Issue #2944758 by oknate, pminf, samuel.mortenson, askibinski: Iframe...
oknate’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks everyone.

Status: Fixed » Closed (fixed)

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