Optionally disable encryption when saving keys#385
Open
gmn42 wants to merge 9 commits intopluginever:masterfrom
Open
Optionally disable encryption when saving keys#385gmn42 wants to merge 9 commits intopluginever:masterfrom
gmn42 wants to merge 9 commits intopluginever:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In some applications, such as tracking of true serial numbers on physical products, database encryption of the numbers provides no benefit and makes troubleshooting and other operations such as db queries more difficult. This patch provides an option to disable encryption when saving serial numbers (a.k.a. "serial keys"). Existing encrypted keys are still read correctly.
A side benefit is that sub-string searches of the numbers works correctly when they are not encrypted (issue #381 ), and numbers are sorted correctly in the list when that column is chosen.
Warning: Previously saved keys will NOT be de-crypted when the option is changed, and it is possible save un-encrypted numbers that match the existing encrypted version, EVEN IF the "no duplicates" option is enabled. Therefore, a method for en/de-crypting the entire table when the option is changed should be developed before using this in production code. Obviously, this is not a concern if starting with an empty table.
For internal use, I use the following function to change the database state after changing the option. It is VERY inefficient, and takes a minute or so to run with around 1800 keys. It takes too much time and memory to run synchronously when the option is changed, and running it asynchronously via schedule_event has been unreliable and has potential for race conditions if the option is changed more than once quickly. Therefore, I run it manually from the shell using
wp eval 'wcsn_resave_keys();'. Obviously, this is not a production solution; hopefully the WCSN team knows of a better approach! (Also, make sure you don't have any keys that start with a.character before using this!)