schematic icon indicating copy to clipboard operation
schematic copied to clipboard

Potential issues with plugin config file settings

Open timkelty opened this issue 7 years ago • 10 comments

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?

timkelty avatar Jun 04 '18 19:06 timkelty

Maybe overriding the settings key of the plugin in the override file with null or an empty array will solve your issue?

bvangennep avatar Jun 04 '18 19:06 bvangennep

@bvangennep for use in importing or exporting?

I tried the following, and the plugin settings were still exported:

plugins:
  assetrev: { }
plugins:
  assetrev: null

timkelty avatar Jun 05 '18 12:06 timkelty

@timkelty did you use this in the override file with the latest schematic version?

boboldehampsink avatar Jun 05 '18 12:06 boboldehampsink

@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?

timkelty avatar Jun 05 '18 12:06 timkelty

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)

timkelty avatar Jun 05 '18 12:06 timkelty

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.

boboldehampsink avatar Jun 05 '18 12:06 boboldehampsink

Ok let me do some more testing and make sure I'm giving your the right info :)

timkelty avatar Jun 05 '18 12:06 timkelty

🤦‍♂️ 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?

timkelty avatar Jun 05 '18 12:06 timkelty

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: {  }

timkelty avatar Jun 05 '18 12:06 timkelty

We'll look into it, for now you should be able to work around it with the override at least.

bvangennep avatar Jun 06 '18 10:06 bvangennep