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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ryankavalsky created an issue. See original summary.

bensti’s picture

same problem after the update

George Bills’s picture

It'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?

icurk’s picture

This 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.

boshtian’s picture

Status: Active » Reviewed & tested by the community

I 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.

  • icurk authored 200da2a on 8.x-1.x
    Issue #2908234 by icurk, George Bills: Undefined index: css_class
    
boshtian’s picture

Status: Reviewed & tested by the community » Fixed
ryankavalsky’s picture

Thank you all! 8.x-4.0-beta2 works like a charm.

bensti’s picture

Great job! beta2 without any error ! thx

Status: Fixed » Closed (fixed)

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