There is major bug between Drupal 8 and H5P module.
Let me explain the steps to regenerate this bug:

1. Let's say we have 2 sites: Site A(Drupal 8) and any other Site B;

2. On Drupal Site A install & enable H5P module;

3. Add H5P interactive field in any content type, let's say "Article";

4. Create "Article" with "H5P content"(doesn't matter which one), for examp. "True/False";

5. In H5P field check "Embed button" and save the node;

6. Go to Site A created node URL, you will see that - node with "H5P content" working fine;

7. Scroll down the node and under created "True/False question" block click "embed" button, the pop-up window should appear with iframe generated code for external sites;

6. Now insert generated iframe code into Site B and save;

7. Ok, let's come back to Site A, go to administration and "Clear all caches"(or you can use in console: drush cr);

8. Now, go to Site B and open the URL where our iframe was inserted, for examp: "http://siteB.com/path-of-page-where-iframe-from-siteA-was-inserted";

9. You will get next error there: "The website encountered an unexpected error. Please try again later.";

10. Also you can see this error if you put iframe's generated URL directly into browser address bar, for examp:"http://siteA.com/en/h5p/1/embed"

11. Again, go back to Site A and see the log messages:

LogicException: The controller result claims to be providing
relevant cache metadata, but leaked metadata was detected. Please
ensure you are not rendering content too early. Returned object class:
Drupal\Core\Render\HtmlResponse. in
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
(line 154 of /home/user/web/siteA.com/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

12. (IMPORTANT!) Problem appears, for users who are NOT authenticated in Site A. So, the content cache is not generated for anonymous users after cache clearing;

13. If we try to open URL for examp.: "http://siteA.com/en/h5p/1/embed" or "http://siteB.com/path-of-page-where-iframe-from-siteA-was-inserted" as a Site A authenticated user, content cache will generate and now anonymous users also can see it without any errors UNTIL next Site A clear caching;

Any ideas?

Comments

emka created an issue. See original summary.

emka’s picture

Issue summary: View changes
emka’s picture

Issue summary: View changes
emka’s picture

Issue summary: View changes
emka’s picture

Issue summary: View changes
paalj’s picture

bevangg’s picture

Bump.
Exact same problem

  • paalj committed 3bad904 on 8.x-1.x
    Issue #2955757: Embed code problem after drupal cache clearing
    
paalj’s picture

With a little help from https://www.drupal.org/project/drupal/issues/2638686, I seem to have found & fixed the problem. Could any of you validate my fix?, then I will release it.

rstotland’s picture

Have what appears to be the same issue. New install of D8 and H5P, works as expected while on the site but embedding the code or going to generated code gives error:

The website encountered an unexpected error. Please try again later.
ArgumentCountError: Too few arguments to function Drupal\h5p\Entity\H5PContent::getH5PIntegrationSettings(), 0 passed in /homepages/40/d747291251/htdocs/clickandbuilds/Drupal/create/modules/h5p/src/Controller/H5PEmbed.php on line 45 and exactly 1 expected in Drupal\h5p\Entity\H5PContent->getH5PIntegrationSettings() (line 192 of modules/h5p/src/Entity/H5PContent.php).
Drupal\h5p\Entity\H5PContent->getH5PIntegrationSettings() (Line: 45)
Drupal\h5p\Controller\H5PEmbed->embed('21')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 666)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

@paalj I would be more than willing to test this as we really need this functionality in upgrading our systems from D7 to D8 with H5P. Thank you
Roman

paalj’s picture

@rstotland: The bug you see has been fixed (but is not released yet): https://cgit.drupalcode.org/h5p/commit/?id=3bad904

rstotland’s picture

Thank you @paalj, i tested the code you have mentioned and the content loads now with the embed link, now trying to resolve the x-frame-options so we can actually embed from our D8 site.

Thank you again

paalj’s picture

Assigned: Unassigned » paalj
Status: Active » Fixed

This was fixed in the 8.x-1.0-rc8 release

paalj’s picture

Status: Fixed » Closed (fixed)