Bugzilla – Attachment 87394 Details for
Bug 21336
GDPR: Handle unsubscribe requests automatically by optional (administrative) lock, anonymize and remove
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21336: (follow-up) Handle strict SQL mode in _anonymize_column
Bug-21336-follow-up-Handle-strict-SQL-mode-in-anon.patch (text/plain), 2.41 KB, created by
Martin Renvoize (ashimema)
on 2019-04-04 08:46:40 UTC
(
hide
)
Description:
Bug 21336: (follow-up) Handle strict SQL mode in _anonymize_column
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-04-04 08:46:40 UTC
Size:
2.41 KB
patch
obsolete
>From e22bd5c06c36308c08335926319fc52f81dd218b Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 17 Dec 2018 09:15:29 +0100 >Subject: [PATCH] Bug 21336: (follow-up) Handle strict SQL mode in > _anonymize_column > >When a field is not nullable we should pass empty string, zero or today >to a char, numeric or date column. >The mandatory parameter does not refer to a database constraint but a Koha >preference. Only for strings we generate a random value. > >Test plan: >Enable strict_sql_modes. >Run t/db_dependent/Koha/Patrons.t again. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron.pm | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 3ad10a8efc..1313d5117d 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1364,26 +1364,29 @@ sub anonymize { > @columns = grep { !/borrowernumber|branchcode|categorycode|^date|password|flags|updated_on|lastseen|lang|login_attempts|flgAnonymized/ } @columns; > push @columns, 'dateofbirth'; # add this date back in > foreach my $col (@columns) { >- if( $mandatory->{lc $col} ) { >- my $str = $self->_anonymize_column($col); >- $self->$col($str); >- } else { >- $self->$col(undef); >- } >+ $self->_anonymize_column($col, $mandatory->{lc $col} ); > } > $self->flgAnonymized(1)->store; > } > > sub _anonymize_column { >- my ( $self, $col ) = @_; >- my $type = $self->_result->result_source->column_info($col)->{data_type}; >+ my ( $self, $col, $mandatory ) = @_; >+ my $col_info = $self->_result->result_source->column_info($col); >+ my $type = $col_info->{data_type}; >+ my $nullable = $col_info->{is_nullable}; >+ my $val; > if( $type =~ /char|text/ ) { >- return Koha::Token->new->generate({ pattern => '\w{10}' }); >+ $val = $mandatory >+ ? Koha::Token->new->generate({ pattern => '\w{10}' }) >+ : $nullable >+ ? undef >+ : q{}; > } elsif( $type =~ /integer|int$|float|dec|double/ ) { >- return 0; >+ $val = $nullable ? undef : 0; > } elsif( $type =~ /date|time/ ) { >- return dt_from_string; >+ $val = $nullable ? undef : dt_from_string; > } >+ $self->$col($val); > } > > =head2 Internal methods >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21336
:
79165
|
79166
|
79167
|
79168
|
79169
|
79170
|
80201
|
80202
|
80203
|
80204
|
80205
|
80206
|
80207
|
80208
|
80213
|
80214
|
80386
|
80387
|
80403
|
81112
|
81113
|
81114
|
81115
|
81116
|
81117
|
81118
|
81119
|
81270
|
81474
|
81475
|
81476
|
81477
|
81478
|
81479
|
81480
|
81481
|
81482
|
81483
|
82051
|
82052
|
82053
|
82054
|
82055
|
82056
|
82057
|
82058
|
82059
|
83202
|
83203
|
83204
|
83205
|
83206
|
83207
|
83208
|
83209
|
83256
|
87158
|
87159
|
87160
|
87161
|
87162
|
87163
|
87164
|
87165
|
87166
|
87167
|
87168
|
87176
|
87177
|
87178
|
87179
|
87180
|
87181
|
87182
|
87183
|
87184
|
87185
|
87387
|
87388
|
87389
|
87390
|
87391
|
87392
|
87393
| 87394 |
87395
|
87396
|
87397
|
87400
|
87401
|
88198
|
88199
|
88217
|
88218