Hi everyone,

A notice appears on a fresh install, 7.23 when I enable the linkit module while using CKEditor 4. In the WYSIWYG CSS settings. I've tried both the define css option and the pull from template option. It also reappears when creating a basic page node.

Here is the error:

Notice: Undefined index: stylesSet in wysiwyg_ckeditor_settings() (line 339 of /var/www/testSite/sites/all/modules/wysiwyg/editors/ckeditor.inc).

Lines 338-342:

 if (!empty($config['buttons']['default']['Styles']) && version_compare($editor['installed version'], '3.2.1', '>=')) {
    if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['stylesSet'])) {
      $settings['stylesSet'] = $styles;
    }
  }

I have tried putting isset() and empty() on the styles variable, and when I do that it makes the node creation page unusable.

Comments

alfthecat’s picture

Title: PHP notice triggered when linkit module is enabled on ckeditor_settings() line 339 » PHP notice triggered on ckeditor_settings() line 339

Getting the same message but without the Linkit module installed.
I noticed the error gets printed as soon as I try to hide the node summary of a body fields (i.e. at /admin/structure/types/manage/article/fields/body#).

Notice: Undefined index: stylesSet in wysiwyg_ckeditor_settings() (line 339 of /var/aegir/platforms/[..]/sites/all/modules/wysiwyg/editors/ckeditor.inc).

Getting this in the latest dev (WYSIWYG 7.x-2.2+23-dev ), didn't see it in the +17 version that I used prior.

I have tried to check the option of using the theme's CSS to see if that helped, but to no avail.

twod’s picture

The notice shows even after you saved the editor profile?

Try

if (!empty($config['buttons']['default']['Styles']) && version_compare($editor['installed version'], '3.2.1', '>=') && !empty($config['stylesSet'])) {
    if ($styles = wysiwyg_ckeditor_settings_parse_styles($config['stylesSet'])) {
      $settings['stylesSet'] = $styles;
    }
  }
alfthecat’s picture

Ho TwoD,

I just rolled back to the +17 dev release but I can surely test the code. But I'm seeing:

['installed version'], '3.2.1',

Does that imply ckeditor 3.x?
Because I use ckeditor 4.x, that might explain something...

twod’s picture

Note that the last parameter to version_compare() is '>=', so this will apply in the case of CKEditor 4.x.

twod’s picture

Note that the Notice is harmless. It's simply stating that a setting is missing from the editor profile. Since the setting is empty, it wont' affect the editor. The setting is related to the Font Style plugin, so this notice only appears when that button/plugin is enabled.

It appears that the editor profile was last saved when the installed CKEditor library was version 3.2.1 or lower, which does not use the stylesSet setting. Since you're now using CKEditor 4.x, Wysiwyg now looks for the value of that setting in the editor profile. I simply forgot to check if that setting was defined before trying to use its value, in case of a situation like this. It does insert a default value for that setting when the editor profile is saved if using a CKEditor version above 3.2.1, so you should no longer see the notice after that.

digitalhorde’s picture

TwoD, thank you so much! This solved my issue, the notice is now gone. It looks like adding !empty($config['stylesSet']) did the trick. I really appreciate you taking the time to help

digitalhorde’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community

This has been tested in my Sandbox and seems to work! Would you like this rerolled as a patch?

rudivanes’s picture

Have the same issue. Can your provide a patch?

twod’s picture

Status: Reviewed & tested by the community » Fixed

I've pushed the patch into 7.x-2.x and 6.x-2.x so the -dev snapshots should be rebuilt within 12 hrs. It just adds the missing !empty($config['stylesSet']) condition to the if statement mentioned above.

Thanks for reporting and participating in the issue!

twod’s picture

For reference, here's the 7.x-2.x commit: 3cb63de.

Status: Fixed » Closed (fixed)

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