From 35ae7b467e54c38b8f99e392b02838e9fd53e9e0 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 26 Jun 2023 15:25:12 +0200 Subject: [PATCH] Bug 31393: Koha::Config: handle the special case for 'content' attribute was wrongly parsed as { key => 'value' } whereas it should be { key => { content => 'value' } } The 'content' attribute is used in shibboleth config Test plan: 1 Run `prove t/Koha/Config.t` Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 6973625e7a06e66ee731ea8f5b69f296943c580f) Signed-off-by: Fridolin Somers --- Koha/Config.pm | 2 +- t/Koha/Config.t | 9 +++++++++ t/data/koha-conf.xml | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Koha/Config.pm b/Koha/Config.pm index eb0671dc2e..f3308c76a7 100644 --- a/Koha/Config.pm +++ b/Koha/Config.pm @@ -239,7 +239,7 @@ sub _read_from_dom_node { delete $subconfig->{id}; } else { my @keys = keys %$subconfig; - if (1 == scalar @keys && $keys[0] eq 'content') { + if (!$node->hasAttributes() && 1 == scalar @keys && $keys[0] eq 'content') { # An element with no attributes and no child elements becomes its text content $subconfig = $subconfig->{content}; } elsif (0 == scalar @keys) { diff --git a/t/Koha/Config.t b/t/Koha/Config.t index b49579c1f7..9f21bdfc2a 100755 --- a/t/Koha/Config.t +++ b/t/Koha/Config.t @@ -131,6 +131,15 @@ subtest 'read_from_file() tests' => sub { } }, 'useshibboleth' => '0', + 'shibboleth' => { + 'autocreate' => '1', + 'matchpoint' => 'userid', + 'mapping' => { + 'userid' => { 'is' => 'uid' }, + 'branchcode' => { 'content' => 'MAIN', 'is' => 'MAIN' }, + 'categorycode' => { 'content' => 'STAFF' }, + }, + }, 'zebra_lockdir' => '/home/koha/var/lock/zebradb', 'lockdir' => '__LOCK_DIR__', 'use_zebra_facets' => '1', diff --git a/t/data/koha-conf.xml b/t/data/koha-conf.xml index 01052920b3..d3a40b356c 100644 --- a/t/data/koha-conf.xml +++ b/t/data/koha-conf.xml @@ -111,6 +111,15 @@ 0 + + 1 + userid + + + + + + /home/koha/var/lock/zebradb __LOCK_DIR__ 1 -- 2.39.5