Closed (fixed)
Project:
File Hash
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Oct 2019 at 16:50 UTC
Updated:
5 Feb 2022 at 01:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
beeyayjay commentedPatch implementing proposed solution.
Comment #3
mfbCan you resolve the coding standards messages at https://www.drupal.org/pift-ci-job/1439666
Comment #4
beeyayjay commentedFixes for coding standards.
Comment #5
beeyayjay commentedFixes remaining indentation issues.
Comment #6
mfbYour specification of the index in filehash_update_7001() isn't working, maybe it needs an "indexes" key?
Comment #7
beeyayjay commentedNot sure why that didn't work, but changed to add index using db_add_index(). That seem to do it
Comment #8
mfbThere is still one coding standards message left to resolve.
Comment #9
mfbThe one downside of this patch is that the table size will be significantly larger.. changing to binary storage of hashes would be a nice future improvement.
Comment #10
beeyayjay commentedYes, SHA-512 is really long. :-(
Anyway, here's the coding standards fix.
Comment #11
beeyayjay commentedFix coding standards indentation issue.
Comment #12
mfbGreat! Thanks!
If you also have time to work on a Drupal 8 version of the patch, that would be amazing...
Comment #13
beeyayjay commentedI'll take a look.
Comment #14
beeyayjay commentedHere's the D8 version.
Comment #15
beeyayjay commentedSorry, coding standards again. This should do it.
Comment #16
mfbRerolled
Comment #17
mfbFixes broken addIndex in the update function (it passed in the full schema array rather than just the "filehash" element).
Comment #18
mfbWrap long line in README file.
Comment #19
mfbVery minor reroll due to README changes.
Comment #20
mfbA while back, PHP added support for the "sha512/256" algorithm.
I wonder if that would meet the needs of this feature request?
Or is full sha512 a requirement for some users?
On the other hand, perhaps we should support dynamic schema specification when algorithms are enabled, and allow anyone to enable whatever hash algorithm they need.
Comment #21
mfbOk here's an improved patch that makes the rest of the SHA-2 and SHA3 algorithms available, modifying the table schema dynamically via the ConfigEvents::SAVE event.
Unfortunately ended up being a kinda big patch, as the new PHP hash algorithm identifiers are not "safe" alphanumeric strings. So I had to add logic to deal w/ that.
Comment #22
mfbUpdate module help text and a couple other fixups.
Comment #23
mfbFix config change logic to handle NULL, e.g. config deleted in Drush.
Comment #24
mfbOk a bunch more changes needed :p
We need to add new column and index in two separate method calls, to work around SQLite issue (wanting the current state of full filehash schema).
Arbitrary config could theoretically be created, so I added some helper functions to validate the config before passing it in to table alter statements. Also separated the translated strings into their own function so these aren't loaded unless needed.
Views data cache was being invalidated incorrectly.
Comment #25
mfbUse a nicer version of algorithm string for SQL column comment.
Comment #26
mfbOk turns out we cannot rely on the "original" config when handling config save events - particularly re: config import, which sets the original to NULL for some reason (#2605144: Original configuration is missing during configuration imports).
So revamping all the config state change logic to try to drop any columns that shouldn't be there, and create any columns that should be present but aren't...
Comment #27
mfbMove any column dropping to a separate batch process - as it can be slow on larger databases and isn't really necessary.
(Adding a column should be fast in many cases thanks to "instant add column")
Comment #28
mfbReport the name of the hash algorithm column currently being deleted to batch engine, and start adding some test coverage for new functionality.
Comment #29
mfbMiscellaneous code cleanup. Guess next time I'll use a merge request, but I think this is getting close
Comment #30
mfbSadly we don't (yet) have a test for content-addressable storage w/ File (Field) Paths module, but I tested with [file:filehash-sha512_256-pair-1]/[file:filehash-sha512_256-pair-2] tokens and appears to work fine.
Comment #31
mfbCleaning up redundant logic in filehash.tokens.inc that calls hash_file() - I don't think this was ever needed, but certainly shouldn't be needed now.
Comment #32
mfbTweak strings from "unused" to "disabled". All we really know is they're disabled.
Comment #34
mfbBack to 7.x-1.x for backport
Comment #35
mfbComment #36
mfbIn case of config imported via features, drush, etc. catch PDOException and add missing database column, if required.
Comment #37
mfbSome fixes for duplicate check.
Comment #38
mfbRemove any invalid configuration elements before using in table alter statements.
Comment #39
mfbFix index name.
Comment #41
mfb