Bug 39482 - Link to edit OpacLibraryInfo from library edit page broken
Summary: Link to edit OpacLibraryInfo from library edit page broken
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Owen Leonard
QA Contact: Lisette Scheer
URL:
Keywords: additional_work_needed
: 40460 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-03-28 16:30 UTC by Owen Leonard
Modified: 2025-08-21 22:19 UTC (History)
6 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes editing and showing OpacLibraryInfo HTML customizations information in the staff interface and OPAC: 1. Staff interface: - When editing a library (Koha administration > Libraries > Actions > Edit) . the links to edit OpacLibraryInfo entries for the OPAC information field are now correct (previously, they may have linked to an incorrect HTML customization) . if there is more than one OpacLibraryInfo entry, all entries are now shown (only one entry was shown previously) - When viewing library information (Koha administration > Libraries > Name > [click library name]), all the OpacLibraryInfo entries are now shown 2. OPAC: - All the entries for a library (including any 'All libraries' entries for OpacLibraryInfo) are now shown on the library information page (from the 'Libraries' link under the quick search bar) - In a record's holdings table, the pop-up window when you click on the current library for an item now correctly shows all entries
Version(s) released in:
Circulation function:


Attachments
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page (14.93 KB, patch)
2025-08-15 13:55 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page (14.98 KB, patch)
2025-08-15 22:17 UTC, David Nind
Details | Diff | Splinter Review
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page (15.04 KB, patch)
2025-08-19 17:58 UTC, Lisette Scheer
Details | Diff | Splinter Review
Bug 39482: (follow-up) Adjust tests (2.63 KB, patch)
2025-08-21 22:18 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2025-03-28 16:30:30 UTC
When editing a library which has OpacLibraryInfo defined there is a link in the form "Edit HTML content". The link passes the wrong id parameter, resulting in an incorrect entry being edited.
Comment 1 Phil Ringnalda 2025-03-31 23:37:32 UTC
Equally bad but more confusing, it seems to be the wrong id parameter unless the right one is currently the highest number there has ever been.

When you you go to test it in ktd, you have to create an OpacLibraryInfo page, and then you see that your link has the right id, 7. Create another sort of HTML customization page, and now the link is wrongly id 9. Delete that second one, your link is still 9.
Comment 2 Owen Leonard 2025-08-15 13:55:58 UTC
Created attachment 185452 [details] [review]
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page

When editing a library which has an associated OpacLibraryInfo HTML
customization the "Edit HTML content" link passes the wrong id
parameter.

To test, apply the patch and restart services.

- Rebuild OPAC CSS.
- Go to Administration -> Libraries.
- Edit a library.
- If there is no OpacLibraryInfo customization associated with that
  library, add at least two OpacLibraryInfo entries and then return to
  the library edit form.
- By the "OPAC information" label you should see all of the
  OpacLibraryInfo entries you added for that library.
- If you have permission to edit HTML customizations you should see
  an edit link.
- Test each to confirm that it opens the correct entry for editing.
- Return to Administration -> Libraries and click the library name to
  view it (rather than edit).
- The correct HTML customizations should appear. If you have permission
  to edit HTML customizations you should see corresponding "Edit" links.
- Test each to confirm that it opens the correct entry for editing.

- In the OPAC, locate a bibliographic record which has one or more items
  from the library you added OpacLibraryInfo to.
- In the holdings table, click the one of the library links to trigger
  the info modal.
- Confirm that all the correct information displays.
- Go to "Libraries" link in the menu under the quick search bar.
- Click the library you modified. Confirm that the correct
  OpacLibraryInfo entries display.

Sponsored-by: Athens County Public Libraries
Comment 3 Owen Leonard 2025-08-15 13:57:18 UTC
This necessitates a change to t/db_dependent/Koha/Library.t but I'm not sure how to do that!
Comment 4 David Nind 2025-08-15 22:17:05 UTC
Created attachment 185484 [details] [review]
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page

When editing a library which has an associated OpacLibraryInfo HTML
customization the "Edit HTML content" link passes the wrong id
parameter.

To test, apply the patch and restart services.

- Rebuild OPAC CSS.
- Go to Administration -> Libraries.
- Edit a library.
- If there is no OpacLibraryInfo customization associated with that
  library, add at least two OpacLibraryInfo entries and then return to
  the library edit form.
- By the "OPAC information" label you should see all of the
  OpacLibraryInfo entries you added for that library.
- If you have permission to edit HTML customizations you should see
  an edit link.
- Test each to confirm that it opens the correct entry for editing.
- Return to Administration -> Libraries and click the library name to
  view it (rather than edit).
- The correct HTML customizations should appear. If you have permission
  to edit HTML customizations you should see corresponding "Edit" links.
- Test each to confirm that it opens the correct entry for editing.

- In the OPAC, locate a bibliographic record which has one or more items
  from the library you added OpacLibraryInfo to.
- In the holdings table, click the one of the library links to trigger
  the info modal.
- Confirm that all the correct information displays.
- Go to "Libraries" link in the menu under the quick search bar.
- Click the library you modified. Confirm that the correct
  OpacLibraryInfo entries display.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2025-08-15 22:51:24 UTC
Is Bug 40460 - Link from branch edition toward OPAC personnalisation is broken, the same a this one?
Comment 6 Owen Leonard 2025-08-18 11:02:49 UTC
I was not aware of Bug 40460, but it is a duplicate. However, I think this patch is more complete because it accommodates cases where there is more than one HTML customization for one library.
Comment 7 Lisette Scheer 2025-08-19 17:58:36 UTC
Created attachment 185561 [details] [review]
Bug 39482: Correct the link to edit OpacLibraryInfo from library edit page

When editing a library which has an associated OpacLibraryInfo HTML
customization the "Edit HTML content" link passes the wrong id
parameter.

To test, apply the patch and restart services.

- Rebuild OPAC CSS.
- Go to Administration -> Libraries.
- Edit a library.
- If there is no OpacLibraryInfo customization associated with that
  library, add at least two OpacLibraryInfo entries and then return to
  the library edit form.
- By the "OPAC information" label you should see all of the
  OpacLibraryInfo entries you added for that library.
- If you have permission to edit HTML customizations you should see
  an edit link.
- Test each to confirm that it opens the correct entry for editing.
- Return to Administration -> Libraries and click the library name to
  view it (rather than edit).
- The correct HTML customizations should appear. If you have permission
  to edit HTML customizations you should see corresponding "Edit" links.
- Test each to confirm that it opens the correct entry for editing.

- In the OPAC, locate a bibliographic record which has one or more items
  from the library you added OpacLibraryInfo to.
- In the holdings table, click the one of the library links to trigger
  the info modal.
- Confirm that all the correct information displays.
- Go to "Libraries" link in the menu under the quick search bar.
- Click the library you modified. Confirm that the correct
  OpacLibraryInfo entries display.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Comment 8 David Nind 2025-08-19 18:00:38 UTC
*** Bug 40460 has been marked as a duplicate of this bug. ***
Comment 9 Lucas Gass (lukeg) 2025-08-20 18:56:20 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 10 Lucas Gass (lukeg) 2025-08-20 21:16:28 UTC
This breaks tests:

prove -v /kohadevbox/koha/t/db_dependent/Koha/Library.t

# Subtest: opac_info tests
    1..8
    # No tests run!
not ok 2 - No tests run for subtest "opac_info tests"

#   Failed test 'No tests run for subtest "opac_info tests"'
#   at /kohadevbox/koha/t/db_dependent/Koha/Library.t line 176.
The method Koha::AdditionalContentsLocalizations->content is not covered by tests!
Comment 11 Lucas Gass (lukeg) 2025-08-20 21:55:18 UTC
(In reply to Owen Leonard from comment #3)
> This necessitates a change to t/db_dependent/Koha/Library.t but I'm not sure
> how to do that!

Sorry Owen, I missed this comment before pushing. For the time being I am reverting this until we can figure out how to adjust those tests.
Comment 12 Lucas Gass (lukeg) 2025-08-21 21:41:33 UTC
For tests, since it is now returning a set of results instead of the best match I think we can get opac_info as a list and check the first thing returned in the array which should be the best result.
Comment 13 Lucas Gass (lukeg) 2025-08-21 22:02:10 UTC
(In reply to Lucas Gass (lukeg) from comment #12)
> For tests, since it is now returning a set of results instead of the best
> match I think we can get opac_info as a list and check the first thing
> returned in the array which should be the best result.

Or maybe not. search_for_display does not seem to return a consistent order.
Comment 14 Lucas Gass (lukeg) 2025-08-21 22:18:06 UTC
Created attachment 185674 [details] [review]
Bug 39482: (follow-up) Adjust tests
Comment 15 Lucas Gass (lukeg) 2025-08-21 22:19:03 UTC
Adjusted a test but let's set it back to 'Signed-off' so someone can double check those tests.