Bug 41976: LinkWrapper no longer mangles links

This patch fixes a bug where, context-dependent, LinkWrapper can keep
referencing back to links that should be out of scope.

This was causing odd behaviour whilst writing Bug 14962 - namely, links
returning as the same value in a table of multiple rows due to
LinkWrapper treating linkData.href as one and the same for each row.

TO TEST:
== APPLY PATCH ==
a)  enable ERMModule syspref, go to /cgi-bin/koha/erm/erm.pl
b)  notice all links and buttons still work as expected
c)  go to /cgi-bin/koha/sip2/sip2.pl
d)  notice all links and buttons still work as expected
e)  go to /cgi-bin/koha/acquisition/vendors
f)  notice all links and buttons still work as expected
g)  enable PreservationModule syspref, go to
/cgi-bin/koha/preservation/home.pl
h)  notice all links and buttons still work as expected
== SIGN OFF ==

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 46fb776762)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Jake Deery 2026-03-03 13:31:07 +00:00 committed by Jacob O'Mara
parent b09e591e83
commit 317694f706
No known key found for this signature in database
1 changed files with 7 additions and 5 deletions

View File

@ -10,7 +10,7 @@
</router-link>
<a
v-else-if="linkData && linkData.href"
:href="linkData.href"
:href="formattedHref"
:class="{ disabled: linkData.disabled }"
>
<slot />
@ -26,6 +26,7 @@ export default {
resource: Object,
},
setup(props) {
const formattedHref = ref(props.linkData?.href);
const formattedParams = ref({});
if (props.linkData && props.linkData.params) {
@ -36,16 +37,17 @@ export default {
}
if (props.linkData?.href && props.linkData.params) {
props.linkData.href += "?";
formattedHref.value += "?";
Object.keys(props.linkData.params).forEach(key => {
props.linkData.href += `${key}=${formattedParams.value[key]}&`;
formattedHref.value += `${key}=${formattedParams.value[key]}&`;
});
props.linkData.href = props.linkData.href.slice(0, -1);
formattedHref.value = formattedHref.value.slice(0, -1);
}
if (props.linkData?.href && props.linkData.slug) {
props.linkData.href += `/${props.resource[props.linkData.slug]}`;
formattedHref.value += `/${props.resource[props.linkData.slug]}`;
}
return {
formattedHref,
formattedParams,
};
},