Bug 37763

Summary: 'Update and run SQL' appends the editor screen after the report results
Product: Koha Reporter: CJ Lynce <cj.lynce>
Component: ReportsAssignee: CJ Lynce <cj.lynce>
Status: Needs documenting --- QA Contact: Julian Maurice <julian.maurice>
Severity: minor    
Priority: P5 - low CC: andrew, barbara.johnson, ctodd, fridolin.somers, julian.maurice, kebliss, lucas, sam.sowanick
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37307
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.04
Circulation function:
Attachments: Bug 37763: SQL reports Update and run SQL inappropriately appends the editor screen after the ran report.
Bug 37763: SQL reports Update and run SQL inappropriately appends the editor screen after the ran report.
Bug 37763: Do not show SQL report editor after 'Update and run'
Bug 37763 (QA follow-up): Tidy

Description CJ Lynce 2024-08-28 18:21:26 UTC
When editing SQL reports, using 'Update and run SQL' inappropriately includes the SQL editor at the bottom of the run report. 
Additionally, this issue causes the saved_sql.id to be appended repeated as described in bug_37307.

Although there certainly could be some usefulness for SQL developers in having the editor appear under the report when testing, the SQL editing box does not function correctly (no auto population of tables, etc.).
This is issues by the CSRF changes made in reports/guided_reports.pl that are causing to 'edit' screen to be appended to the 'run' screen.

1) Login to staff client
2) Navigate to Reports -> Create from SQL
3) Create a short report (SELECT * FROM items), name it and SAVE it.
4) On the resulting "Edit SQL report' page, click 'Update and run SQL'
5) See the report runs, but at the 'Edit SQL report' screen shows at the bottom (it should not)
Comment 1 CJ Lynce 2024-08-28 18:47:35 UTC
Created attachment 170839 [details] [review]
Bug 37763: SQL reports Update and run SQL inappropriately appends the editor screen after the ran report.

This patch corrects an error where the SQL editor screen would appear after the
	report results when using 'Update and run SQL' when editing reports.
This also corrects a related issue where the saved_sql.id of the report would
	be repeatedly appended to SQL code when using 'Update and run SQL'.

To test:
1) Login to staff client
2) Navigate to Reports -> Create from SQL
3) Create a short report (SELECT * FROM items), name it and SAVE it.
4) On the resulting "Edit SQL report' page, click 'Update and run SQL'
5) See the report runs, but at the 'Edit SQL report' screen shows at the bottom.
6) Apply Patch
7) Return to Reports -> Saved Reports and Edit the report you created.
8) On "Edit SQL report' page, click 'Update and run SQL'
9) Verify that the report runs, but the 'Edit SQL report' section is gone.

Sponsored-by: Westlake Porter Public Library
Comment 2 SamSowanick 2024-09-04 19:27:30 UTC
I tried Sign Off but the issue was not present on 24.06.00. I still have this issues on 24.05.02 (our test server). The Sandbox I was using doesn't allow to set specific versions (as far as I can tell).
Comment 3 CJ Lynce 2024-09-04 20:21:04 UTC
Puzzling. I just re-verified the issue exists on the latest main in my KTD, as well as in ByWater's sandbox. In the event my steps are ambiguous, I have to first "Edit" a report (after creating), and use the "Update and run SQL" button for the behavior.
Comment 4 Biblibre Sandboxes 2024-09-04 21:04:10 UTC
Created attachment 171039 [details] [review]
Bug 37763: SQL reports Update and run SQL inappropriately appends the editor screen after the ran report.

This patch corrects an error where the SQL editor screen would appear after the
	report results when using 'Update and run SQL' when editing reports.
This also corrects a related issue where the saved_sql.id of the report would
	be repeatedly appended to SQL code when using 'Update and run SQL'.

To test:
1) Login to staff client
2) Navigate to Reports -> Create from SQL
3) Create a short report (SELECT * FROM items), name it and SAVE it.
4) On the resulting "Edit SQL report' page, click 'Update and run SQL'
5) See the report runs, but at the 'Edit SQL report' screen shows at the bottom.
6) Apply Patch
7) Return to Reports -> Saved Reports and Edit the report you created.
8) On "Edit SQL report' page, click 'Update and run SQL'
9) Verify that the report runs, but the 'Edit SQL report' section is gone.

Sponsored-by: Westlake Porter Public Library
Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
Comment 5 SamSowanick 2024-09-04 21:05:15 UTC
I found the error in my ways, thanks for the clarification.

Signed off.

Sam.
Comment 6 Julian Maurice 2024-09-06 09:06:09 UTC
Created attachment 171130 [details] [review]
Bug 37763: Do not show SQL report editor after 'Update and run'

This patch corrects an error where the SQL editor screen would appear
after the report results when using 'Update and run SQL' when editing
reports.
This also corrects a related issue where the saved_sql.id of the report
would be repeatedly appended to SQL code when using 'Update and run
SQL'.

To test:
1) Login to staff client
2) Navigate to Reports -> Create from SQL
3) Create a short report (SELECT * FROM items), name it and SAVE it.
4) On the resulting "Edit SQL report' page, click 'Update and run SQL'
5) See the report runs, but at the 'Edit SQL report' screen shows at the
   bottom.
6) Apply Patch
7) Return to Reports -> Saved Reports and Edit the report you created.
8) On "Edit SQL report' page, click 'Update and run SQL'
9) Verify that the report runs, but the 'Edit SQL report' section is
   gone.

Sponsored-by: Westlake Porter Public Library
Signed-off-by: Sam Sowanick <sam.sowanick@corvallisoregon.gov>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 7 Julian Maurice 2024-09-06 09:06:11 UTC
Created attachment 171131 [details] [review]
Bug 37763 (QA follow-up): Tidy

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 8 Julian Maurice 2024-09-06 09:07:41 UTC
Added a tidy follow-up and reworded the first commit message so that it tells what the patch does instead of what the bug is.
Comment 9 Katrin Fischer 2024-09-13 11:19:02 UTC
Follow-up failed QA script for the commit message. Fixed before pushing.
Comment 10 Katrin Fischer 2024-09-13 11:58:28 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 11 Lucas Gass (lukeg) 2024-09-23 20:36:37 UTC
Backported to 24.05.x for upcoming 24.05.04
Comment 12 Brendan Lawlor 2024-09-27 15:03:42 UTC
*** Bug 37307 has been marked as a duplicate of this bug. ***
Comment 13 Fridolin Somers 2024-10-21 12:49:52 UTC
CUD not in 23.11.x
Comment 14 Phil Ringnalda 2024-10-24 19:15:41 UTC
*** Bug 38245 has been marked as a duplicate of this bug. ***