Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After enabling the module, the following notice appears in the logs.
Notice: Undefined index: #tag in Drupal\http2_server_push\Asset\CssCollectionRenderer->render() (line 53...
Comment | File | Size | Author |
---|---|---|---|
#15 | 2842347-15.patch | 5.14 KB | Wim Leers |
|
Comments
Comment #2
DamienMcKennaThis is a workaround, but it'd be worthwhile checking to see what $element contains to see why those variables don't exist in case there's another bug (or API change) somewhere.
Comment #3
hitfactory CreditAttribution: hitfactory commentedConfirming patch in #2 works and gets rid of notices.
FYI, the error is being thrown for $elements['prefetch'] which, in my case, is an empty array.
Comment #4
Wim LeersInteresting! I wonder how one can reproduce this. On which URLs is this happening? AFAICT there are only two possible ways to get this:
external
CSSIf that can be confirmed, then this will be committed & released right away :)
Comment #5
hitfactory CreditAttribution: hitfactory commentedWe have a request which runs on every page which returns a JSON response. Could it be that?
The request object returns the URL of the page I'm on so not sure how to check if it is the JSON route tripping it up.
Note that, we're also using the Advanced CSS/JS Aggregation module. Will check now to see if the error is still thrown without that module enabled.
Comment #6
Wim LeersThanks for checking those things!
Comment #7
hitfactory CreditAttribution: hitfactory commentedAfter uninstalling Advanced CSS/JS Aggregation module, the notice disappears.
I see in Drupal\advagg\AssetCssCollectionRenderer, $elements['prefetch'] gets initialized to an empty array so if that is valid, then I guess the patch is needed after all.
Comment #8
Wim LeersSo indeed,
advagg
is doing this:in
\Drupal\advagg\Asset\CssCollectionRenderer::render()
.The solution in #2 works, but is not quite correct. I think this is correct.
Comment #10
Wim LeersComment #11
hitfactory CreditAttribution: hitfactory commented'prefetch' is returned as one of the values in Element::children($elements) so undefined index notice is back with patch in #8.
Looks like a combination of #2 and #8 is required as it seems the isset($element['#tag']) check is still needed.
Comment #12
Wim LeersAdvagg just released version 2.2 to fix this: http://cgit.drupalcode.org/advagg/commit/?h=8.x-2.x&id=0396b6a799a09ea47....
Sadly, the fix is incomplete; in fact, it causes D8 to break entirely. Once #2859132: Error: Unsupported operand types in Drupal\advagg\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries() (line 64) is in, this is really fixed. Once that's also fixed in Advagg, then this problem will have disappeared.
Comment #13
Wim LeersHowever, that being said, I now see that #8 was completely wrong. I even wonder now what I was thinking then :)
The code in
http2_server_push
should simply be more robust. So, here's the code to make that more robust.Comment #14
Wim Leers#13 fixes the problem. But let's be super thorough so that we don't ever have to deal with this again. Let's make it really ensure all assumptions are met, and let's fix it not only in
\Drupal\http2_server_push\Asset\CssCollectionRenderer
but also in\Drupal\http2_server_push\Asset\JsCollectionRenderer
.Comment #15
Wim LeersFixing this nit.
Comment #16
Wim LeersComment #17
Wim LeersZero coding standards violations:
Comment #19
Wim Leers