Bugzilla – Attachment 77890 Details for
Bug 21222
Patron's creation is broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21222: (bug 20226 follow-up) Fix patron creation
Bug-21222-bug-20226-follow-up-Fix-patron-creation.patch (text/plain), 6.74 KB, created by
Martin Renvoize (ashimema)
on 2018-08-16 11:07:27 UTC
(
hide
)
Description:
Bug 21222: (bug 20226 follow-up) Fix patron creation
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-08-16 11:07:27 UTC
Size:
6.74 KB
patch
obsolete
>From ae9a5028ae95b3e44e86a70bb20a653a66e0633d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Aug 2018 16:30:09 -0300 >Subject: [PATCH] Bug 21222: (bug 20226 follow-up) Fix patron creation > >Since bug 20226 you cannot longer creation a patron, memberentry.pl will >explode with >Template process failed: undef error - DBIC result _type isn't of the >_type Category at /home/vagrant/kohaclone/koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc >line 22. > >The problem is that "patron" is actually defined and the test in >str/members-menu.inc does not work as expected. > >It comes from > commit 7b1d08df0f4f69c52826c80a13158245287f4c00 > Bug 19936: Replace Generate_Userid - Update the occurrences >where I needed $patron to be defined in order to use Koha::Patron->generate_userid >on an blessed object. >But this was actually wrong, as it could have side-effects. > >Test plan: >Create a new patron >Edit it >Retest bug 19936 and make sure the userid is generated correctly in the >different situations > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/modules/members/memberentrygen.tt | 20 +++++++++++++++--- > members/memberentry.pl | 21 ++++++++++--------- > 2 files changed, 28 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 0b77bfcd91..695b1e29a5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -4,7 +4,17 @@ > [% USE Branches %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Patrons › [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF categoryname %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</title> >+<title>Koha › Patrons › >+ [% UNLESS blocking_error %] >+ [% IF ( opadd ) %]Add >+ [% ELSIF ( opduplicate ) %]Duplicate >+ [% ELSE %] Modify >+ [% END %] patron >+ [% IF (firstname) %][% firstname %] [% END %] >+ [% IF (surname) %][% surname %] [% END %] >+ ([%IF categoryname %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %]) >+ [% END %] >+</title> > [% INCLUDE 'doc-head-close.inc' %] > </head> > >@@ -12,15 +22,19 @@ > [% INCLUDE 'header.inc' %] > [% INCLUDE 'patron-search.inc' %] > >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › >-[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]</a> ›[% END %] >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> >+ [% UNLESS blocking_error %] >+ ›[% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname | html %] [% END %][% IF (surname) %][% surname | html %] [% END %]</a> ›[% END %] > <strong>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron ([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</strong> >+ [% END %] > </div> > [% IF ( opadd ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %] > > <div id="bd"> > <div id="yui-main"> > <div class="yui-b"> >+ [% INCLUDE 'blocking_errors.inc' %] > [% IF error_alert %] > [% IF ( error_alert == "no_email" ) %] > <div class="error">This member has no email</div> >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 2bf1a02f19..cb4d0506ac 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -160,9 +160,8 @@ if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) { > > $borrower_data = $patron->unblessed; > $borrower_data->{category_type} = $patron->category->category_type; >-} else { >- $patron = Koha::Patron->new; > } >+ > my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; > my $category_type = $input->param('category_type') || ''; > unless ($category_type or !($categorycode)){ >@@ -285,21 +284,23 @@ $newdata{'lang'} = $input->param('lang') if defined($input->param('lang')) > # builds default userid > # userid input text may be empty or missing because of syspref BorrowerUnwantedField > if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) { >+ my $fake_patron = Koha::Patron->new; >+ $fake_patron->userid($patron->userid) if $patron; # editing > if ( ( defined $newdata{'firstname'} || $category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) { > # Full page edit, firstname and surname input zones are present >- $patron->firstname($newdata{firstname}); >- $patron->surname($newdata{surname}); >- $patron->generate_userid; >- $newdata{'userid'} = $patron->userid; >+ $fake_patron->firstname($newdata{firstname}); >+ $fake_patron->surname($newdata{surname}); >+ $fake_patron->generate_userid; >+ $newdata{'userid'} = $fake_patron->userid; > } > elsif ( ( defined $data{'firstname'} || $category_type eq 'I' ) && ( defined $data{'surname'} ) ) { > # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used > # Still, if the userid field is erased, we can create a new userid with available firstname and surname > # FIXME clean thiscode newdata vs data is very confusing >- $patron->firstname($data{firstname}); >- $patron->surname($data{surname}); >- $patron->generate_userid; >- $newdata{'userid'} = $patron->userid; >+ $fake_patron->firstname($data{firstname}); >+ $fake_patron->surname($data{surname}); >+ $fake_patron->generate_userid; >+ $newdata{'userid'} = $fake_patron->userid; > } > else { > $newdata{'userid'} = $data{'userid'}; >-- >2.18.0
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 21222
:
77801
|
77811
| 77890