Version 2.3 added support for storing plugin version and some settings in profiles.

Problem

When editor is configured and exported to features, the export captures all changes correctly (plugin version etc). But when reverting from this exported code in another environment, the changes are not applied and profile UI reports that plugin version is not what is expected in profile Re-export of the config from this environment produces code with NULL values:

Originally exported values

// Exported profile: filtered_html
  $profiles['filtered_html'] = array(
    'format' => 'filtered_html',
    'editor' => 'ckeditor',
     // SNIP
    ),
    'preferences' => array(
      'default' => 1,
      'user_choose' => 0,
      'show_toggle' => 1,
      'add_to_summaries' => 0,
      'version' => '4.6.1.580bcaf',
    ),
    'name' => 'formatfiltered_html',
  );

Values after feature revert->feature update on another environment

// Exported profile: filtered_html
  $profiles['filtered_html'] = array(
    'format' => 'filtered_html',
    'editor' => 'ckeditor',
     // SNIP
    ),
    'preferences' => array(
      'add_to_summaries' => NULL,
      'default' => NULL,
      'show_toggle' => NULL,
      'user_choose' => NULL,
      'version' => NULL,
    ),
    'name' => 'formatfiltered_html',
  );

How to reproduce

1. Install this module and CKeditor on clean environment.
2. Go to WYSIWYG profiles UI and check that plugin version is discovered. (all good)
3. Edit a profile and enable some checkboxes ("Enabled by default" etc).
4. Create a feature and export this profile. The exported code will contain correct values. (all good)
5. Go to new environment and revert exported feature.
6. Go to WYSIWYG profiles page and note that there is a warning "CKEditor (Expected version: but found 4.6.1.580bcaf.)" (bad, the version of the plugin has not been imported during feature revert).
7. Edit the profile and note that previously checked checkboxes ("Enabled by default" etc) are not selected. (bad)

Also, Features UI shows the following error:

Notice: Undefined index: add_to_summaries in wysiwyg_features_rebuild() (line 85 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: default in wysiwyg_features_rebuild() (line 86 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: show_toggle in wysiwyg_features_rebuild() (line 87 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: user_choose in wysiwyg_features_rebuild() (line 88 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Trying to get property of non-object in wysiwyg_features_rebuild() (line 96 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: add_to_summaries in wysiwyg_features_rebuild() (line 85 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: default in wysiwyg_features_rebuild() (line 86 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: show_toggle in wysiwyg_features_rebuild() (line 87 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Undefined index: user_choose in wysiwyg_features_rebuild() (line 88 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Notice: Trying to get property of non-object in wysiwyg_features_rebuild() (line 96 of /var/beetbox/docroot/sites/all/modules/contrib/wysiwyg/wysiwyg.features.inc).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex.designworks created an issue. See original summary.

alex.skrypnyk’s picture

Title: 2.3 Profile config is not reverted from features » v2.3 Some profile config and plugin version is not reverted from features
Issue summary: View changes
alex.skrypnyk’s picture

Issue summary: View changes
alex.skrypnyk’s picture

Issue summary: View changes
alex.skrypnyk’s picture

Title: v2.3 Some profile config and plugin version is not reverted from features » Profile preferences and plugin version is not reverted from features
alex.skrypnyk’s picture

Title: Profile preferences and plugin version is not reverted from features » Profile preferences and plugin version are not reverted from features
alex.skrypnyk’s picture

I have reviewed the code in wysiwyg_features_rebuild() and it had some issues that were related to not storing preferences into the correct location under settings.

Also, there is an issue with retrieving editor information from function wysiwyg_get_editor() as object, but the function returns an array.

Another issue was related to spelling of $preferences variable.

All these issues are fixed in attached path. It was tested with multiple feature updates and reverts.

alex.skrypnyk’s picture

Status: Active » Needs review

  • TwoD committed 3d0de0b on 7.x-2.x authored by alex.designworks
    - #2841479 by alex.designworks: Fixed profile preferences and plugin...
TwoD’s picture

Status: Needs review » Fixed

Excellent, works just like you said, stupid mistake on my part for not catching that earlier.

Status: Fixed » Closed (fixed)

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

Sardis’s picture

I've noticed small CS errors, so i dare to fix them.
However, nice work, @alex.designworks!

TwoD’s picture

@Sardis,
Thanks for the whitespace cleanups, but please note that the original patch has already been committed so your patch will not apply against the current branch HEAD.

I also think this would be more suitable as a follow-up CS-issue referencing this one for when the problem got introduced. Then we can track status of just the cleanup changes vs mixing it with the functionality change made here. (And I could actually credit you for providing the cleanup patch.)

Sardis’s picture

Actually, this excessive whitespace $settings = &$profile['preferences']; has been fixed already in #2851200: Update verified version range issue, along with proper version exporting.
So i beg your pardon.