schematic
schematic copied to clipboard
Potential issues with plugin config file settings
Some plugins have settings thats cannot be translated to static values (e.g. closures), that are explicitly set in config files.
I recently ran into an issue with https://github.com/clubstudioltd/craft-asset-rev, where I exported (and later imported) but didn't notice that it imported the settings from my config/assetrev.php file.
In fact, that plugin has NO CP-set config options, so when they get entered in the DB via Schematic things get weird.
Furthermore, one value is a anonymous fn, which ended up importing as null, which broke things.
Any ideas on how to handle this, other than just excluding plugins?
Maybe overriding the settings key of the plugin in the override file with null or an empty array will solve your issue?
@bvangennep for use in importing or exporting?
I tried the following, and the plugin settings were still exported:
plugins:
assetrev: { }
plugins:
assetrev: null
@timkelty did you use this in the override file with the latest schematic version?
@boboldehampsink Yeah, 4.0.8
The above overrides file worked for import ( via craft schematic/import --override-file=config/overrides.yml), but had not affect on export.
Is that expected?
Separate issue, but I think its a little confusing that export automatically picks up config/overrides.yml but import doesn't? (unless I'm missing something)
Well, since 4.0.8 the exported yaml is overridden with the override contents. And the override file is also automatically picked up in importing ;-) The argument flag is there if you want to use an other location or filename for the override file.
Ok let me do some more testing and make sure I'm giving your the right info :)
🤦♂️ ok all is working with override…I named my file overrides.yml 😁
So…back to the original issue - I'm wondering if Schematic should detect if a value is non-primitive (closure, etc) and throw an error when exporting?
FWIW, I tried this and it did not work:
My goal was to still export plugins.assetrev.isEnabled and plugins.assetrev.isInstalled but skip over plugins.assetrev.settings, though I suppose thats more of an excludes thing than an override.
plugins:
assetrev:
settings: { }
We'll look into it, for now you should be able to work around it with the override at least.