-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Bulk Edit Tests and Tweaks #14707
Merged
Merged
Bulk Edit Tests and Tweaks #14707
+271
−23
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PR Summary
Each of these modifications contributes to improved system security, code quality, and test coverage, resulting in a more robust and reliable software. |
spencerrlongg
commented
May 9, 2024
Comment on lines
-382
to
-403
$decrypted_old = Helper::gracefulDecrypt($field, $asset->{$field->db_column}); | ||
|
||
/* | ||
* Check if the decrypted existing value is different from one we just submitted | ||
* and if not, pull it out of the object since it shouldn't really be updating at all. | ||
* If we don't do this, it will try to re-encrypt it, and the same value encrypted two | ||
* different times will have different values, so it will *look* like it was updated | ||
* but it wasn't. | ||
*/ | ||
if ($decrypted_old != $this->update_array[$field->db_column]) { | ||
$asset->{$field->db_column} = \Crypt::encrypt($this->update_array[$field->db_column]); | ||
} else { | ||
if (Gate::allows('admin')) { | ||
$decrypted_old = Helper::gracefulDecrypt($field, $asset->{$field->db_column}); | ||
|
||
/* | ||
* Remove the encrypted custom field from the update_array, since nothing changed | ||
* Check if the decrypted existing value is different from one we just submitted | ||
* and if not, pull it out of the object since it shouldn't really be updating at all. | ||
* If we don't do this, it will try to re-encrypt it, and the same value encrypted two | ||
* different times will have different values, so it will *look* like it was updated | ||
* but it wasn't. | ||
*/ | ||
unset($this->update_array[$field->db_column]); | ||
unset($asset->{$field->db_column}); | ||
} | ||
if ($decrypted_old != $this->update_array[$field->db_column]) { | ||
$asset->{$field->db_column} = Crypt::encrypt($this->update_array[$field->db_column]); | ||
} else { | ||
/* | ||
* Remove the encrypted custom field from the update_array, since nothing changed | ||
*/ | ||
unset($this->update_array[$field->db_column]); | ||
unset($asset->{$field->db_column}); | ||
} | ||
|
||
/* | ||
* These custom fields aren't encrypted, just carry on as usual | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think this diff is so weird because of the added indentation 😢
Nice work! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This introduces some bulk edit tests, includes some tweaks to factories, an extra gate, and the flipping of keys and values in an array.
The key value flip is because the array was originally
'id' => 'key'
but now is properly
'key' => 'id'
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
These are tests. 😄
Test Configuration: