The report service URL generates JSON, but has no header information. It would be nice to have: https://.../cgi-bin/koha/svc/report?id=15 Return just the JSON with no header entry, and: https://.../cgi-bin/koha/svc/report?id=15&header=1 Return the JSON with the first entry as a header entry. And while I'm at it, I'll update the license and strict/warnings to Modern::Perl.
Created attachment 24000 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available.
Created attachment 24001 [details] [review] Bug 11491 - Missing header fields in JSON data Added a header parameter, which when non-empty will add the header fields of the query in question as the first element of the JSON array. TEST PLAN --------- 1) Log into staff client 2) Reports 3) Used save reports 4) Click the Action button on any report 5) Click Edit 6) Make the report public 7) Update the SQL 8) Note the ID number of the report 9) In a new tab https://.../cgi-bin/koha/svc/report?id=## 10) The returned JSON should not have a header. 11) Go to https://.../cgi-bin/koha/svc/report?id=##&header=1 12) The returned JSON should have a header. 13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 NOTE: There are two patches, but you could just test 1.
Created attachment 24002 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available.
In the test plans, did you mean: https://.../cgi-bin/koha/opac/svc/report?id=## Not: https://.../cgi-bin/koha/svc/report?id=## ? Or should kohaclone/svc/report also add headers?
The ... is the OPAC reference, so the svc maps accordingly based on the Apache configuration. There is no reason to do it for the staff client, since I don't expect people to try to make public reports run from the staff client.
Is there a reason that private reports should not have headers? :)
Hm, I just double checked - it's possible to run the report from the staff URL, so you will only get access to the data when you are logged in. I can see use cases for that when you want to make sensitive data available to another service. I think it would make sense to add the headers to both. Example URL: <staffurl>/cgi-bin/koha/svc/report?id=3
Created attachment 24909 [details] [review] Bug 11491 - Missing header fields in JSON data Added a header parameter, which when non-empty will add the header fields of the query in question as the first element of the JSON array. Added header ability to staff svc/report as well. Moved code around to make diffs between svc/report and opac/svc/report smaller. TEST PLAN --------- 1) Log into staff client 2) Reports 3) Used save reports 4) Click the Action button on any report 5) Click Edit 6) Make the report public 7) Update the SQL 8) Note the ID number of the report 9) In a new tab https://.../cgi-bin/koha/svc/report?id=## 10) The returned JSON should not have a header. 11) Go to https://.../cgi-bin/koha/svc/report?id=##&header=1 12) The returned JSON should have a header. 13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 NOTE: There are two patches, but you could just test 1.
Created attachment 24910 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available (for OPAC).
I think changing it to be my $lines = $sth->fetchall_arrayref({}); Which hands back an array of hashrefs is nicer, the JSON output of it is also a lot nicer and a lot easier to deal with in Javascript. Shall I do a counter patch?
Created attachment 24911 [details] [review] Bug 11491 - Missing field names in JSON data Added a parameter (annotated), which when non-empty will generate an array of hashes that include the field names as keys, not the typical array of field values, for the JSON output. Added functionality to staff svc/report as well. Moved code around to make diffs between svc/report and opac/svc/report smaller. TEST PLAN --------- 1) Apply the patch 2) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 NOTE: There are two patches, but you could just test 1. 3) Log into staff client 4) Reports 5) Used save reports 6) Click the Action button on any report WITHOUT PARAMETERS. -- with parameters blows up in master and this. 7) Click Edit 8) Make the report public 9) Update the SQL 10) Note the ID number of the report 11) Note the ID number of a non-public report 12) In a new tab use the number from step 9. https://OPAC/cgi-bin/koha/svc/report?id=## -- matches default master report. https://OPAC/cgi-bin/koha/svc/report?id=##&annotated=1 -- has hash where the keys are the field name. https://STAFF/cgi-bin/koha/svc/report?id=## -- matches default master report. https://STAFF/cgi-bin/koha/svc/report?id=##&annotated=1 -- has hash where the keys are the field name. 13) In a new tab use the number from step 10. https://OPAC/cgi-bin/koha/svc/report?id=## -- matches the warning from master. https://OPAC/cgi-bin/koha/svc/report?id=##&annotated=1 -- matches the warning from master. https://STAFF/cgi-bin/koha/svc/report?id=## -- matches default master report. https://STAFF/cgi-bin/koha/svc/report?id=##&annotated=1 -- has hash where the keys are the field name. 14) In a new tab use a crazy number like 9675309 such that the report does not exist. https://OPAC/cgi-bin/koha/svc/report?id=## -- tells you the report doesn't exist vs. master giving a Software error. https://OPAC/cgi-bin/koha/svc/report?id=##&annotated=1 -- tells you the report doesn't exist vs. master giving a Software error. https://STAFF/cgi-bin/koha/svc/report?id=## -- tells you the report doesn't exist vs. master giving a Software error. https://STAFF/cgi-bin/koha/svc/report?id=##&annotated=1 -- tells you the report doesn't exist vs. master giving a Software error.
Created attachment 24912 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available (for OPAC).
Created attachment 24913 [details] [review] Bug 11491 - Missing field names in JSON data Added a parameter (annotated), which when non-empty will generate an array of hashes that include the field names as keys, not the typical array of field values, for the JSON output. Added functionality to staff svc/report as well. Moved code around to make diffs between svc/report and opac/svc/report smaller. TEST PLAN --------- 1) Log into staff client 2) Reports 3) Used save reports 4) Click the Action button on any report WITHOUT PARAMETERS. -- with parameters blows up in master and this. 5) Click Edit 6) Make the report public 7) Update the SQL 8) Note the ID number of the report 9) Note the ID number of a non-public report 10) Make up a crazy ID number for a non-existant report 11) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: Sorry this report is not public https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. 12) Apply the patch 13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 -- There should be no problems. All OK. 14) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: Sorry this report is not public https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154.
Created attachment 24914 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available (for OPAC).
Created attachment 24915 [details] [review] Bug 11491 - Missing field names in JSON data Added a parameter (annotated), which when non-empty will generate an array of hashes that include the field names as keys, not the typical array of field values, for the JSON output. Added functionality to staff svc/report as well. Moved code around to make diffs between svc/report and opac/svc/report smaller. TEST PLAN --------- 1) Log into staff client 2) Reports 3) Used save reports 4) Click the Action button on any report WITHOUT PARAMETERS. -- with parameters blows up in master and this. 5) Click Edit 6) Make the report public 7) Update the SQL 8) Note the ID number of the report 9) Note the ID number of a non-public report 10) Make up a crazy ID number for a non-existant report 11) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: Sorry this report is not public https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. 12) Apply the patch 13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 -- There should be no problems. All OK. 14) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of hashes with field names as keys https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: There is no such report. https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: There is no such report. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of hashes with field names as keys https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of hashes with field names as keys https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: There is no such report. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: There is no such report.
Created attachment 24916 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&header=blah Where ## reflects a public report available (for OPAC).
Created attachment 24917 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&annotated=blah Where ## reflects a public report available (for OPAC).
Test plans for each patch are in the patch. See comment 15 and comment 17.
Created attachment 24923 [details] [review] Bug 11491 - Missing field names in JSON data Added a parameter (annotated), which when non-empty will generate an array of hashes that include the field names as keys, not the typical array of field values, for the JSON output. Added functionality to staff svc/report as well. Moved code around to make diffs between svc/report and opac/svc/report smaller. TEST PLAN --------- 1) Log into staff client 2) Reports 3) Used save reports 4) Click the Action button on any report WITHOUT PARAMETERS. -- with parameters blows up in master and this. 5) Click Edit 6) Make the report public 7) Update the SQL 8) Note the ID number of the report 9) Note the ID number of a non-public report 10) Make up a crazy ID number for a non-existant report 11) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: Sorry this report is not public https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. 12) Apply the patch 13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 -- There should be no problems. All OK. 14) In a new tab (with the appropriate edits) https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of hashes with field names as keys https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- Software error: Sorry this report is not public https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: There is no such report. https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: There is no such report. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 -- JSON data has arrays of hashes with field names as keys https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 -- JSON data has arrays of field values. https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 -- JSON data has arrays of hashes with field names as keys https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 -- Software error: There is no such report. https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 -- Software error: There is no such report. Signed-off-by: Holger Meißner <h.meissner.82@web.de>
Created attachment 24924 [details] [review] Bug 11491 - Old License and strict, warnings Replaced License text with latest one from http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence and tweaked copyright lines accordingly. Also changed use strict and use warnings into use Modern::Perl as per PERL2 from the coding guidelines. TEST PLAN --------- 1) less ~/kohaclone/opac/svc/report - The license does not reflect the current license - This will have use strict and use warnings 2) Apply patch - The license should be corrected 3) It should still run https://.../cgi-bin/koha/svc/report?id=## https://.../cgi-bin/koha/svc/report?id=##&annotated=blah Where ## reflects a public report available (for OPAC). Signed-off-by: Holger Meißner <h.meissner.82@web.de>
Works as described.
Created attachment 24960 [details] [review] 24923: Bug 11491 - Missing field names in JSON data
Created attachment 24961 [details] [review] 24924: Bug 11491 - Old License and strict, warnings
Pushed to master. Thanks, Mark!
*** Bug 26286 has been marked as a duplicate of this bug. ***