generateFileHash() and validateFileHash() should be colocated
authorTim Otten <totten@civicrm.org>
Tue, 12 Feb 2019 23:50:40 +0000 (15:50 -0800)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 22 Feb 2019 00:15:09 +0000 (11:15 +1100)
commitc5c40df7bdee3747831d141e1041ecc8ac171ea9
tree86ff1dd80b7fcb8c1a34d295c6378e1cc40718e1
parentb68895ad8bf8892e4d7f1161747e1dc38c6e8927
generateFileHash() and validateFileHash() should be colocated

The two functions (`generateFileHash()` and `validateFileHash()`) are
tightly-coupled.  Most changes to one would require a matching change in the
other.  So they should be parallel.

It'd be OK to say "the hash formula is a general utility for any party using
file APIs" (so put `generateFileHash()` and `validateFileHash()` in `CRM_Core_BAO_File`).

It'd be OK to say "the hash formula is specific to the end-point/page which
serves files" (so put `generateFileHash()` and `validateFileHash()` in
`CRM_Core_Page_File`).

The former feels a bit more accurate, so I pushed it toward that.
CRM/Core/BAO/File.php
CRM/Core/Page/File.php
tests/phpunit/api/v3/AttachmentTest.php