View | Details | Raw Unified | Return to bug 32426
Collapse All | Expand All

(-)a/Koha/Patron.pm (-8 / +7 lines)
Lines 1818-1831 sub has_valid_userid { Link Here
1818
    $patron->generate_userid;
1818
    $patron->generate_userid;
1819
1819
1820
    If you do not have a plugin for generating a userid, we will call
1820
    If you do not have a plugin for generating a userid, we will call
1821
    the legacy method here that returns firstname.surname[.number],
1821
    the internal method here that returns firstname.surname[.number],
1822
    where number is an optional suffix to make the userid unique.
1822
    where number is an optional suffix to make the userid unique.
1823
    (Its behavior has not been changed on bug 32426.)
1823
    (Its behavior has not been changed on bug 32426.)
1824
1824
1825
    If you have plugin(s), the first valid response will be used.
1825
    If you have plugin(s), the first valid response will be used.
1826
    A plugin is assumed to return a valid userid as suggestion, but not
1826
    A plugin is assumed to return a valid userid as suggestion, but not
1827
    assumed to save it already.
1827
    assumed to save it already.
1828
    Does not fallback to legacy (you could arrange for that in your plugin).
1828
    Does not fallback to internal (you could arrange for that in your plugin).
1829
    Clears userid when there are no valid plugin responses.
1829
    Clears userid when there are no valid plugin responses.
1830
1830
1831
=cut
1831
=cut
Lines 1837-1848 sub generate_userid { Link Here
1837
    );
1837
    );
1838
    unless( @responses ) {
1838
    unless( @responses ) {
1839
        # Empty list only possible when there are NO enabled plugins for this method.
1839
        # Empty list only possible when there are NO enabled plugins for this method.
1840
        # In that case we provide legacy response.
1840
        # In that case we provide internal response.
1841
        return $self->_generate_userid_legacy;
1841
        return $self->_generate_userid_internal;
1842
    }
1842
    }
1843
    # If a plugin returned false value or invalid value, we do however not return
1843
    # If a plugin returned false value or invalid value, we do however not return
1844
    # legacy response. The plugins should deal with that themselves. So we prevent
1844
    # internal response. The plugins should deal with that themselves. So we prevent
1845
    # unexpected/unwelcome legacy codes for plugin failures.
1845
    # unexpected/unwelcome internal codes for plugin failures.
1846
    foreach my $response ( grep { $_ } @responses ) {
1846
    foreach my $response ( grep { $_ } @responses ) {
1847
        $self->userid( $response );
1847
        $self->userid( $response );
1848
        return $self if $self->has_valid_userid;
1848
        return $self if $self->has_valid_userid;
Lines 1851-1857 sub generate_userid { Link Here
1851
    return $self;
1851
    return $self;
1852
}
1852
}
1853
1853
1854
sub _generate_userid_legacy { # as we always did
1854
sub _generate_userid_internal { # as we always did
1855
    my ($self) = @_;
1855
    my ($self) = @_;
1856
    my $offset = 0;
1856
    my $offset = 0;
1857
    my $firstname = $self->firstname // q{};
1857
    my $firstname = $self->firstname // q{};
1858
- 

Return to bug 32426