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.
Using Features v7.x-2.3 and WYSIWYG v7.x-2.2+54-dev (2014-10-18), when you modify a WSYWIYG profile it does not export properly when doing "features-update".
The full scenario:
- Have an existing site with CKEditor v3.5.x and the above releases of Features and WYSWYG, with the current configuration exported to a feature which is also enabled..
- Update to the latest CKEditor v4.
- Go to the profile page for the text format that CKEditor is available for.
- Make adjustments, hit save.
- Use "drush features-update [featurename]" to update the wysiwyg configuration.
- Deploy the changes to another instance of the site and revert the feature.
- Load up a node/add/* form, the WYSIWYG will not be correct, there will be differences versus the original instance where the changes were applied.
- On the second site instance, load up the same WYSIWYG profile edit page, hit save.
- The changes will now properly take effect on the node/add/* form.
I've seen this happen where a button for the Footnotes module was not being disabled until after going back into the profile edit form and hitting save again.
Comment | File | Size | Author |
---|---|---|---|
#11 | wysiwyg-feature_export_object_to_array-2414575-10-7.patch | 1.14 KB | HLopes |
#5 | features_export_doesn_t-2414575-5.patch | 493 bytes | kalinchernev |
Comments
Comment #1
DamienMcKennaHere's a test scenario:
Scenario A is the {wysiwyg}.settings value from the second instance after deploying the changes and then using the command "drush fr -y [featurename]" to load them onto the server. Scenario B is the same database record after manually re-saving the same form. Note that there are a bunch of different values in the array.
Comment #2
DamienMcKennaBumping this to major as it indicates that exportables just are not working correctly.
Comment #3
TwoDThe dumps you posted are valid profiles, but it looks to me like the feature wasn't updated at all.
Your scenario A is missing the 'add_to_summaries' and 'default_toolbar_grouping' keys introduced a while ago in Wysiwyg 7.x-2.x-dev (the only version supporting CKEditor 4), suggesting it's from Wysiwyg 7.x-2.2.
Those keys are present in the second scenario, with the exception of the footnotes plugin (likely because it wasn't detected).
Do you have the feature code itself, as it was created from the original site after the profile was saved (to apply profile changes) and 'drush features-update' was run?
Comment #4
TwoDI just created a new feature, noted its state was "default" after being enabled, modified the profile, state changed to "overridden", recreated the feature, state changed to "default".
I didn't have a second site to test with, and I recreated the feature using the Features UI instead of Drush, but the result should be the same since Wysiwyg won't know the difference.
Comment #5
kalinchernev CreditAttribution: kalinchernev as a volunteer commented+1 for having issues with features exports from wysiwyg.
Digging quite deep, I am prone to propose an update in either wysiwyg_features_revert() or wysiwyg_features_rebuild() hooks, which are responsible for applying the exported configurations to the target staging/prod environments.
Reasoning
- wysiwyg utilizes features hooks to export *.features.wysiwyg.inc file. Exported profile is (object)
- wysiwyg_features_revert() is directly calling wysiwyg_features_rebuild(). Both hooks are used to apply (object) to database. These are features module hooks, which are not alterable by other modules.
- wysiwyg_features_rebuild() is assuming that $profile is an array, not an (object). Thus, rebuild and revert on target instance can never happen.
I tried:
- finding alter hooks on hook_features_revert() and hook_features_rebuild(), didn't find any. I cannot intercept in between to turn the $profile into array.
- re-export via different methods to do the stupidity test. Both drush and browser are using came way to export $profile.
My idea about a quick-fix is the casting just before the query at wysiwyg_features_rebuild(). I believe it relates to the issue as the rebuild and revert features are in the base of the configurations migration.
Comment #6
kalinchernev CreditAttribution: kalinchernev as a volunteer commentedComment #7
TwoDI forgot to mention I also reverted and had the feature rebuilt. Everything works well in my tests.
@kalinchernev, Wysiwyg profiles are not exported as objects. I'm not sure how you arrived to that result.
Here is a sample created with Features 2.x and the current Wysiwyg 7.x-2.x (code in wysiwyg.features.inc is identical to 7.x-2.2):
(This may also expect a foo.features.filter.inc file with the corresponding filter.)
Start with the profile in the same state as the exported on-file profile.
Test 1, reverts:
This calls
wysiwyg_features_revert()
and thenwysiwyg_features_rebuild()
. The$profile
variable is an array as it's read directly from the file. (Tested using Devel'sdd()
.)Wysiwyg implements 'faux-exportables' as it always needs database entries for profiles and can't use the on-file versions directly.
'Faux-exportables' use
hook_features_rebuild()
to be told when the on-file data has changed so the DB entries can be updated.Test 2, restores:
'Strike' => 1,
line in foo.features.wysiwyg.inc.The act of visiting the Features overview page triggers Features to call
hook_features_rebuild()
directly, if the on-file data has changed compared to the cached version, and it's not 'Overridden'. (Clearing the cache has the same effect if enabled in Features.)Again, the
$profile
variable is an array because it gets the value from the exported file.Comment #8
anthonylindsay CreditAttribution: anthonylindsay commentedSimilar to the above comment in #7, I've experienced the following:
This was with Features 2 and Wysiwyg 7.x-2.x-dev
Comment #9
TwoD@anthonylindsay, that should not happen. Features should not auto-revert unless you have some other module which does it for you. I've seen some sites do it as they control every single change via code pushes (they often don't even have the UI modules enabled) so in case something did change any configuration
Features does auto-rebuild non-overridden features if the exported file has changed on cache-clear, if the setting to do that is enabled. Compared to the above use case, this would happen when devs do push up new features code and does a cache clear, so the changes get applied even if they forget to manually revert changes after the code update. This would theoretically work if you don't have the UI enabled (unless it isn't actually implemented in the Features UI module), only have FTP-access to your server, and could not use drush to revert features after uploading new code.
Either case, Wysiwyg itself does not control when a revert or rebuild happens, it just acts as ordered.
Comment #10
HLopes CreditAttribution: HLopes commentedI'm seeing the same behaviour described in #5.
The problem is this cast:
Removing it manually makes the problem go away.
Features version: 7.x-2.9
Wysiwyg version: 7.x-2.2
This is what I obtain after using the Features UI to create a feature.
Comment #11
HLopes CreditAttribution: HLopes commentedFirst stab at a patch to fix this.
Comment #12
DamienMcKennaComment #13
TwoDI can not reproduce this in the current 7.x-2.x-dev branch. A couple of features related fixes have been committed which I hope should fix this as well.
In my tests so far there has been no need for the explicit array cast. Profiles are exported as arrays and loaded as arrays with Features 7.x-2.10. There is no cast to an object as seen in the sample from #10.
Can anyone still reproduce this? If not, I'll assume it's been fixed.
Comment #14
HLopes CreditAttribution: HLopes commentedThe problem seems to originate from this patch, as mentioned on the comment after that one.
Comment #15
TwoDOk, so once that patch gets into Features we would have a problem in Wysiwyg, which the patches here attempt to fix. That explains why I couldn't reproduce it. Thank you @HLopes.
Will see if I can verify this ASAP.
Comment #17
TwoDThis does look like a useful precaution in case that patch is being used (or Features ever commits it), so I have added it to 7.x-2.x.
Thank you all!