underpin icon indicating copy to clipboard operation
underpin copied to clipboard

Introduce better way to normalize, and hash items

Open alexstandiford opened this issue 2 years ago • 0 comments

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.

alexstandiford avatar Jul 28 '21 15:07 alexstandiford