Closed (fixed)
Project:
Encrypt
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Dec 2012 at 22:00 UTC
Updated:
2 Sep 2014 at 04:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gregglesAn exception is probably the right thing here.
Comment #2
cellar door commentedI've added a check for the key after we retrieve it, throw an error if it's not found and then return FALSE by which the implementing module should then be able to react to. Also I've fixed a minor error in the drupal settings conf implementation that was throwing errors.
Comment #3
gregglesReturning false is a bit different than throwing an exception. I think the function should return a consistent data structure in all cases and throw and exception if there is a problem.
Comment #4
cellar door commentedI toyed around with doing a throwing an exception but the only issue is it'll break the exisiting supported modules (including field encrypt) because no one is setup to catch the exception.
For example the implementation in field encrypt is:
this will throw fatal errors without having the catch. If we catch it internally what should we do then to notify the other modules that there was an error.
I agree that an exception would be the best way but it'd take patches to all existing modules to do (which could be ok since we are moving to 2.x but wouldn't be a clean upgrade path).
Thoughts?
Comment #5
gregglesFor the form encrypt module we plan to delete that anyway so nothing to fix (#2283073: Move the encryptfapi sub-module). The townsend key management module seems like it should be easy to modify to handle an exception given the maintainers of that are actively involved in this queue as well. Are there others?
IMO this is the time to break the API to make improvements.
Comment #6
cellar door commentedThe Townsend key management module won't be effected by this change as it's only handling the keys and encryption itself. This would add more redundancy to it as well as any future key provider modules.
I agree that now's the time to break the API to make it stronger. We'll want to make a note then to Field Encrypt (who we're still trying to get in hold of to push some changes as well) and other encryption maintainers that the 2.x branch will need them to update. The core encrypt-1.x -> 2.x shouldn't break though.
Attached a new patch for this that replaces the return FALSE with a new exception thrown that we'll have to catch in the implementing modules.
Comment #7
cellar door commentedJust saw I forgot to update the status
Comment #9
cellar door commentedGreg - is the issue above an error in the test or how I'm throwing the exception? I'm thinking the test needs to be altered to allow for a reply other than an encrypted value.
Comment #10
gregglesI saw the failure, but didn't look into the details of the failing test.
I just requeued the testing for the 7.x-2.x branch on https://drupal.org/node/543396/qa so that we can get a fresh result. Did you try running the tests locally with and without the patch?
Comment #11
cellar door commentedYeah I did a simple test with the following code that caught the exception properly:
I believe the error here is in the test - will debug it further to find out this afternoon.
Comment #12
gregglesSorry, I meant did you try running the simpletests of this module using the testing framework built into Drupal?
The test passes fine on its own https://drupal.org/node/543396/qa so I guess the problem is actually introduced by this patch. Maybe it is indicative of more fundamental bug of the tests for the module that we just haven't found to date, but some investigation will be necessary to figure that out.
Comment #13
cellar door commentedGotcha - I'll debug the testing locally. My guess is that we're now returning only an Exception that the test is currently not setup to catch that could be causing the issue (thus the result is the same as the input since it wasn't encrypted). I'll dive into the test and see if it needs some tweaking for the new exception handling.
Real world testing though shows that this is the fix we need, just need to make sure our own test parameters are setup to match.
Comment #14
cellar door commented6: nokey-1867114-6.patch queued for re-testing.
Comment #15
cellar door commentedLooks like it passed on a restest. I tested it locally as well and all appeared to be good (though I found a typo in the encrypt.test file). Not sure as to why the test would fail the first time but it appears good now.
Would you like me to add a test into the Encryption Method Plugin Test to check this exception or just leave it as "Needs Review"?
Comment #16
gregglesThat is quite odd. Thanks for your work on the code and figuring out the test situation.
I think tests should be mandatory for the way things *should* be working. Tests for failure conditions are less of a priority to me, but if you wanted to do that it seems great.
Seems good to me, but let's wait a while for reviews and feedback before committing.
Comment #17
crashtest_ commentedNo other feedback or reviews have happened, looks like you guys like it, want to commit it?
Comment #18
rlhawkI'm getting errors when using the File provider after applying this patch to the latest dev version of the module, so marking as "Needs work" while I investigate.
Comment #19
rlhawkI figured out the problem. Here's a slightly modified patch.
Comment #20
crashtest_ commentedTested this by moving my file key out of the directory and received the correct error:
Also received an error in the watchdog log:
Looks good to me.
Comment #21
rlhawkGreat, thanks. This is committed.