Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Plugin schemaVersion is cached in plugins.php and can't be updated #2419

Closed
khalwat opened this issue Feb 9, 2018 · 2 comments
Closed

Plugin schemaVersion is cached in plugins.php and can't be updated #2419

khalwat opened this issue Feb 9, 2018 · 2 comments

Comments

@khalwat
Copy link
Contributor

khalwat commented Feb 9, 2018

If you created a plugin that has a schemaVersion in the extra array, this data is cached in the plugins.php file by Craft.

If you then have db migrations that you want to run, you can't update the schemaVersion in your composer.json because Craft doesn't look there for it when loading the plugin. Instead, it looks at the cached into if has in plugins.php

If you then try to update the public property $schemaVersion in your plugin's primary class, this unfortunately is stomped on by the schemaVersion that is cached in the plugins.php file.

The only solution is to uninstall and re-install the plugin (which could potentially involve data loss, depending on the plugin), or manually edit the plugins.php file to remove the schemaVersion key/value pair.

I'll modify generate-craftplugin to remove the schemaVersion field from the composer.json and move it to the public property $schemaVersion but this does create a bit of an issue for any existing plugins that might run into this situation.

@khalwat
Copy link
Contributor Author

khalwat commented Feb 9, 2018

Lindsey noted that if will check the schemaVersion if you bump the plugin's version number as well, so this actually may be a non-issue, if that's the intended functionality.

@brandonkelly
Copy link
Member

brandonkelly commented Feb 9, 2018

The only solution is to uninstall and re-install the plugin (which could potentially involve data loss, depending on the plugin), or manually edit the plugins.php file to remove the schemaVersion key/value pair.

This is only the case for path repos, where Composer doesn't ever re-check the repo when running composer update. If the plugin is installed via a composer repo (either Packagist or the Plugin Store), then vendor/craftcms/plugins.php will be updated when the plugin is updated, per the latest info in the plugin’s composer.json.

Lindsey noted that if will check the schemaVersion if you bump the plugin's version number as well, so this actually may be a non-issue, if that's the intended functionality.

That’s not actually true; the two are always checked independently of each other.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants