Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Introduce better way to normalize, and hash items #38

Open
alexstandiford opened this issue Jul 28, 2021 · 0 comments
Open

Introduce better way to normalize, and hash items #38

alexstandiford opened this issue Jul 28, 2021 · 0 comments

Comments

@alexstandiford
Copy link
Collaborator

alexstandiford commented Jul 28, 2021

Right now, there are a number of circumstances where Underpin generates a hash, and sometimes that has is generated from an array of arguments. These are all normalized in their own places using some basic sorting functionality when-necessary. It would be nice Underpin had some built-in functions to handle some annoying PHP things that are common, like:

  1. Recursive sorting of arrays
  2. Convert an array of data to be serialize-able (eg: a closure in an array will fail if serialized)
  3. Generating quick hashes, as well as secure hashes

I don't know where, but number 2 in-particular will ineviatably cause issues, or because it's not being done right, we're probably running into potential for hash collissions.

Introducing these methods would make it a little easier to work with arrays and hashes while also ensuring that current hashes work consistently.

The hash should also always prefix hashes with the string underpin at the beginning. This will allow distributed plugins that use Underpin's package command to automatically override this prefix with whatever they rename underpin to.

Ironically enough, I also think the recursinve array sorting and data normalization should probably be stored in the object cache so it can be accessed again quicker should this function need to run multiple times with the same array.

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

No branches or pull requests

1 participant