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: Laura Escamilla <laura.escamilla@bywatersolutions.com>
(cherry picked from commit 12fdf33139)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
This commit is contained in:
Jake Deery 2026-03-03 13:31:07 +00:00 committed by Baptiste Wojtkowski
parent b64f41a235
commit 7e16e85e4f
No known key found for this signature in database
GPG Key ID: 47A8A13E10BC0D40
1 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,57 @@
<template>
<router-link
v-if="linkData && linkData.name"
:to="{
name: linkData.name,
params: formattedParams,
}"
>
<slot />
</router-link>
<a
v-else-if="linkData && linkData.href"
:href="formattedHref"
:class="{ disabled: linkData.disabled }"
>
<slot />
</a>
<slot v-else />
</template>
<script>
import { ref } from "vue";
export default {
props: {
linkData: Object,
resource: Object,
},
setup(props) {
const formattedHref = ref(props.linkData?.href);
const formattedParams = ref({});
if (props.linkData && props.linkData.params) {
Object.keys(props.linkData.params).forEach(key => {
formattedParams.value[key] =
props.resource[props.linkData.params[key]];
});
}
if (props.linkData?.href && props.linkData.params) {
formattedHref.value += "?";
Object.keys(props.linkData.params).forEach(key => {
formattedHref.value += `${key}=${formattedParams.value[key]}&`;
});
formattedHref.value = formattedHref.value.slice(0, -1);
}
if (props.linkData?.href && props.linkData.slug) {
formattedHref.value += `/${props.resource[props.linkData.slug]}`;
}
return {
formattedHref,
formattedParams,
};
},
};
</script>
<style></style>