libreform / wp-libre-form

Easy native HTML5 forms for WordPress. Version 1.5 is unmaintained, but works without issue. 2.0 has been rewritten from the ground, and can be found at https://github.com/libreform/libreform
https://wordpress.org/plugins/wp-libre-form
GNU General Public License v3.0
67 stars 27 forks source link

Meta `_wplf_plugin_version` even update was not selected #150

Closed timiwahalahti closed 5 years ago

timiwahalahti commented 5 years ago

Even the Yes, update when I save the form checkbox is not checked, meta value _wplf_plugin_version is saved to contain the version number 1.5.0.1. That meta value should not be saved if the checkbox is not active. It might quite possibly break things.

timiwahalahti commented 5 years ago

@k1sul1 you've done this feature, like to check this out?

This situation can happen, when the plugin is updated before the single form is saved. In that case, _wplf_plugin_version contains the version number of the updated plugin, not the plugin where the form was created. This might cause problems with additional fields and others in the future.

Maybe use upgrader_process_complete hook to save some legacy version number to old forms after the plugin has updated? Tho this won't work if the plugin is updated manually.

Maybe add an admin_init hook with simple WP_Query checking the existence of _wplf_plugin_version meta and adding legacy version to forms without version? It is somewhat expensive, but works and is the most effective way to deal with this problem.

k1sul1 commented 5 years ago

I don't like the upgrader_process_complete hook because it doesn't fire when managing plugins with Composer, or when updating them manually.

If the version indeed updates, even when the checkbox is not checked, that's a bug, I'll check it out. The version is meant to be used if we ever ad a feature that changes how something works, like when we added additional field validation.