Bugzilla – Attachment 192842 Details for
Bug 41780
Show first name if preferred name is empty on the patron's detail page (moremember.tt)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41780: (follow-up) Update preferred name field if empty
Bug-41780-follow-up-Update-preferred-name-field-if.patch (text/plain), 3.35 KB, created by
Ayoub Glizi-Vicioso
on 2026-02-09 19:14:41 UTC
(
hide
)
Description:
Bug 41780: (follow-up) Update preferred name field if empty
Filename:
MIME Type:
Creator:
Ayoub Glizi-Vicioso
Created:
2026-02-09 19:14:41 UTC
Size:
3.35 KB
patch
obsolete
>From 97bb38875a97e274b1322c560f7bcf6225e57e66 Mon Sep 17 00:00:00 2001 >From: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >Date: Mon, 9 Feb 2026 14:13:37 -0500 >Subject: [PATCH] Bug 41780: (follow-up) Update preferred name field if empty > >--- > Koha/Patron.pm | 34 ++++++++++++++++++- > .../prog/en/includes/patron-title.inc | 7 ++-- > 2 files changed, 37 insertions(+), 4 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index c0ef6e292c..2e3fb4906b 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -196,6 +196,37 @@ sub plain_text_password { > return; > } > >+sub preferred_name { >+ >+ my ( $self ) = @_; >+ >+ my $val = $self->_result->preferred_name; >+ >+ return $self->{_cached_preferred_name} if exists $self->{_cached_preferred_name}; >+ >+ if ( !defined $val || $val =~ /^\s*$/ ) { >+ my $fname = $self->firstname; >+ if ( defined $fname && $fname ne '' ) { >+ >+ return $fname if (!$self->in_storage || $self->_result->is_changed); >+ >+ eval { >+ $self->_result->update({ preferred_name => $fname }); >+ $self->_result->discard_changes; >+ }; >+ >+ if ($@) { >+ warn "Non-fatal: Could not auto-sync preferred_name for patron " . $self->borrowernumber . ": $@"; >+ } >+ >+ return $fname; >+ } >+ } >+ >+ $self->{_cached_preferred_name} = $val; >+ return $val; >+} >+ > =head3 store > > Patron specific store method to cleanup record >@@ -240,7 +271,7 @@ sub store { > if C4::Context->preference("uppercasesurnames"); > > # Add preferred name unless specified >- unless ( $self->preferred_name ) { >+ if ( !defined $self->preferred_name || $self->preferred_name =~ /^\s*$/ ) { > $self->preferred_name( $self->firstname ); > } > >@@ -424,6 +455,7 @@ sub store { > > # Final store > $self = $self->SUPER::store; >+ > } > } > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >index 97b7a9f113..0796a36104 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >@@ -77,9 +77,10 @@ > [%- END -%] > [%- ELSE -%] > [%- IF (data.title) %][%- WRAPPER maybe_span field_name='patron_title' -%][%- data.title _ ' ' | html -%][%- END -%][%- END -%] >- [%- IF data.preferred_name -%][%- WRAPPER maybe_span field_name='preferred_name' -%][%- data.preferred_name | html %][% END -%][% END -%] >- [%- IF !(data.preferred_name) -%] >- [%- WRAPPER maybe_span field_name = 'firstname' -%][%- data.firstname |html %][% END -%] >+ [%- IF ( patron.preferred_name ) -%] >+ [%- WRAPPER maybe_span field_name='preferred_name' -%][%- patron.preferred_name | html %][%- END -%] >+ [%- ELSIF ( data.firstname ) -%] >+ [%- WRAPPER maybe_span field_name = 'firstname' -%][%- data.firstname | html -%][%- END -%] > [%- END -%] > [%- IF data.middle_name -%][%- WRAPPER maybe_span field_name='middle_name' -%][% ' ' _ data.middle_name | html -%][%- END -%][%- END -%] > [%- IF data.othernames -%] >-- >2.52.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 41780
:
192651
|
192841
| 192842