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.
I just updated to 8.x-4.0-beta1 and am getting a bunch of "Undefined index: css_class" errors at the top of any page that employs Context. Here's the full message:
Notice: Undefined index: css_class in Drupal\context\Plugin\ContextReaction\Blocks->execute() (line 195 of modules/context/src/Plugin/ContextReaction/Blocks.php).
Comment | File | Size | Author |
---|---|---|---|
#4 | context_2908234_undefined-index-css_class_4.patch | 972 bytes | icurk |
#3 | context.php7_warnings.patch | 1.18 KB | George Bills |
Comments
Comment #2
bensti CreditAttribution: bensti commentedsame problem after the update
Comment #3
George Bills CreditAttribution: George Bills commentedIt's to do with PHP7 warning on things that work fine in PHP~5.6. e.g.
$x = $arr['y']
in PHP~5.6 works fine regardless of if 'y' is a valid key or not (it'll just return NULL if it's not a valid key). In 7 you get warnings.I've attached a patch that seems to work on my end.
One other (much more minor) issue - does the code really need to do
$block->getConfiguration()
so much? It sets$configuration = $block->getConfiguration()
first thing, so why not just use that instead of calling the method over and over?Comment #4
icurk CreditAttribution: icurk at Agiledrop - Your Trusted Drupal Teammates commentedThis warning occurs because the newest version of context module has additional CSS class option on each block configuration form. I created a patch, which updates all blocks configurations and adds CSS class setting to it. You will need to run drush updb, to update the blocks configurations and then all warnings should disappear.
Comment #5
boshtian CreditAttribution: boshtian commentedI agree with @icurk, let's just write an update hook that will solve blocks added in previous versions of Context. The one above is working just fine.
The point is that this value will always be there, it's the new feature that we added and it only affects blocks that were added before the update.
As this is a major issue, I will also create new release (beta2), so you'll be able to update without patching. And of course, you need to run updb, as @icurk already mentioned.
@George Bills: you can create a separate issue for the minor issue you mentioned in your comment and write a patch for it.
Comment #7
boshtian CreditAttribution: boshtian commentedComment #8
ryankavalsky CreditAttribution: ryankavalsky commentedThank you all! 8.x-4.0-beta2 works like a charm.
Comment #9
bensti CreditAttribution: bensti commentedGreat job! beta2 without any error ! thx