Problem
I discovered this issue when I was trying to modify the placeholder HTML code.
When I changed the placeholder HTML in BigPipeStrategy.php, BigPipe stopped working.
After investigating into the problem, I found that there are two occurrence of basically the same string:
Line 168 in file BigPipeStrategy.php:
return [
'#markup' => '<div data-big-pipe-placeholder-id="' . Html::escape($big_pipe_placeholder_id) . '"></div>',
Line 419 in file BigPipe.php:
$fragments = explode('<div data-big-pipe-placeholder-id="', $html);
array_shift($fragments);
$order = [];
foreach ($fragments as $fragment) {
$t = explode('"></div>', $fragment, 2);Proposed solution
Replace those 2 occurrences with reference to the same string. I tried adding a new BigPipeConfig.php, but there should be more elegant ways to do so.
Comments
Comment #1
Anonymous (not verified) commentedztl8702 created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedHere is the patch. Incorrect. Removed.
I moved the placeholder HTML into
BigPipeConfig.php.In order to demonstrate the effects of customized placeholder HTML, I also added a css file which just turns placeholders' background into red.
Comment #3
Anonymous (not verified) commentedIncorrect. Removed.
Comment #4
Anonymous (not verified) commentedComment #5
Anonymous (not verified) commentedComment #6
Anonymous (not verified) commentedAlso, the implementation of getPlaceholderOrder (BigPipe.php line 419) does not look robust to me.
I am still studying the code though.
It is possible to store that placeholder order information somewhere (in memory)? Because it should have been known when the placeholders are generated.
Comment #7
Anonymous (not verified) commentedComment #8
Anonymous (not verified) commentedUpdate
The patches above were for big_pipe-rc1.
However this issue still exist in the lastest dev version (big_pipe.module of Drupal core 8.2.x).
Comment #9
Anonymous (not verified) commentedThis patch from #2632750: Interface previews/skeleton screens through optional "preview" or "placeholder" templates seems to provide a more robust implemation of
getPlaceholderOrder:https://www.drupal.org/node/2632750#comment-10874352
Comment #10
Anonymous (not verified) commentedComment #11
wim leersPlease participate in #2632750: Interface previews/skeleton screens through optional "preview" or "placeholder" templates. This is a duplicate of that.