On bug 17591 we discovered that there was something weird going on with
the way we export and use subroutines/modules.
This patch tries to standardize our EXPORT to use EXPORT_OK only.
That way we will need to explicitely define the subroutine we want to
use from a module.
This patch is a squashed version of:
Bug 17600: After export.pl
Bug 17600: After perlimport
Bug 17600: Manual changes
Bug 17600: Other manual changes after second perlimports run
Bug 17600: Fix tests
And a lot of other manual changes.
export.pl is a dirty script that can be found on bug 17600.
"perlimport" is:
git clone https://github.com/oalders/App-perlimports.git
cd App-perlimports/
cpanm --installdeps .
export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib"
find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \;
The ideas of this patch are to:
* use EXPORT_OK instead of EXPORT
* perltidy the EXPORT_OK list
* remove '&' before the subroutine names
* remove some uneeded use statements
* explicitely import the subroutines we need within the controllers or
modules
Note that the private subroutines (starting with _) should not be
exported (and not used from outside of the module except from tests).
EXPORT vs EXPORT_OK (from
https://www.thegeekstuff.com/2010/06/perl-exporter-examples/)
"""
Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.
@EXPORT and @EXPORT_OK are the two main variables used during export operation.
@EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace.
@EXPORT_OK does export of symbols on demand basis.
"""
If this patch caused a conflict with a patch you wrote prior to its
push:
* Make sure you are not reintroducing a "use" statement that has been
removed
* "$subroutine" is not exported by the C4::$MODULE module
means that you need to add the subroutine to the @EXPORT_OK list
* Bareword "$subroutine" not allowed while "strict subs"
means that you didn't imported the subroutine from the module:
- use $MODULE qw( $subroutine list );
You can also use the fully qualified namespace: C4::$MODULE::$subroutine
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
The test files do not need to return 1
Patch generated with:
perl -p -i -e "s/^1;\n//xsm" t/**/*.t
Test plan:
git grep '^1;$' t/**/*.t
should not return any results
NOTE: does not fix C4/SIP/t, nor xt tests.
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
REPLICATE ISSUE:
perl t/Koha.t -> fails
AFTER THIS PATCH AND DEPENDENCIES:
perl t/Koha.t -> OK
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Is 'instantiations' even a word?
Use a Test::DBIx::Class defaults instead.
Save your keyboard and prevent horrible bugs from emerging from rampant code duplication.
This change doesn't seem to have any impact on the speed of executing those tests.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This is an optional follow up depending on community opinion.
While copying over the code form the ISBN portion I noticed that with
aggressive matching enabled invalid ISBNs (and hence ISSNs) were being
stripped from the record.
I think in the case of a library exporting records, making changes, and
reimporting they would expect to get a match on ISSN or ISBN whether or
not the number is valid.
This patch changes the subroutine to return the original ISSN in the
case of it being invalid.
To test:
With first patch only export a record with an invalid ISSN and reimport
with AggressiveMatchOnISSN enabled and match on ISSN - you should not get a match
Apply this patch
reimport the file and you should find a match.
Signed-off-by: Chad Roseburg <croseburg@ncrl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This patch adds a syspref "AggressiveMatchOnISSN" allowing for a match
of ISSNs with or without hyphens. It uses Business::ISSN in order to
follow the use of Business::ISBN and allow for validation of ISSNs
To test:
1 - Find a record in your system with an ISSN (or add one)
2 - Stage a record containing the same ISSN but lacking a hyphen
3 - Matching on ISSN should find 0 matches
4 - Repeat with no hyphen ISSN in system and hyphen ISSN in import
5 - Matching should find 0
6 - Apply patch
7 - Update datbase and install Business::ISSN
8 - Leave AggressiveMatchOnISSN as don't and repeat original tests- no
change
9 - Set AggressiveMatchOnISSN as do and repeat original test
10 - You should find a match
11 - prove t/Koha.t - all tests pass
Sponsored by North Central Regional Library System (NCRL) www.ncrl.org
Signed-off-by: Chad Roseburg <croseburg@ncrl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4::Koha::IsAuthorisedValueCategory contains only 2 useful calls, from
C4::Reports::Guided and reports/guided_reports.pl
It can be replaced with
Koha::AuthorisedValues->search({ category => $authorised_value})->count
Test plan:
1/ Create a sql report using an authorised value category, something
like:
SELECT COUNT(*) FROM items where itemlost=<<lost|LOST>>
2/ Execute the report and confirm that everything works fine.
3/ Create a sql report using a nonexistent authorised value categor,
something like:
SELECT COUNT(*) FROM items where itemlost=<<lost|NONEXIST>>
4/ When saving the report, you should get a warning message
"lost: The authorized value category (NONEXIST) you selected does not exist."
5/ Save anyway and execute the report, you should get the same warning
message.
QA:
git grep IsAuthorisedValueCategory
should not return any results
prove t/db_dependent/ReportsGuided.t
should return green
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as described
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
This subroutine does not make sense anymore (Koha::DateUtils should be
used) and is no longer used.
It can be removed safely.
Test plan:
git grep slashifyDate
should not return any results
prove t/Koha.t
and
prove t/db_dependent/Koha.t
should return green
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
slashifyDate removed, all test pass successfully
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Tests in t/ should always pass for building the Debian packages
for Koha. But we've started using Test::DBIx::Class for writing
mocked tests, and that lib is not (yet) packaged fro Debian 7+.
This means build is failing. Devs and jenkins use the lib from CPAN.
This patch makes the tests skip if the lib is absent.
To test:
- Install Test::DBIx::Class
$ sudo cpanm Test::DBIx::Class
- Run the tests:
$ prove t/
=> SUCCESS: Tests pass
- Uninstall Test::DBIx::Class
$ sudo cpan -U Test::DBIx::Class
- Run the tests:
$ prove t/
=> SUCCESS: Tests still pass (those needing the lib are skipped)
- Sign off :-D
Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised. All test pass successful
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Warning: This patch modifies a module!
What's the need of the binary function here?
The data are case insensitive, so no need to use this mysql function.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Karen Bryant <kbryant@ccpl-fl.net>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
To test:
[1] Run prove -v t/Koha.t. The last test should fail.
[2] Apply the main patch for this bug.
[3] Run prove -v t/Koha.t again. This time, all tests should pass.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This patch adds a regression test for C4::Koha::NormalizeISBN
throwing an exception when trying to parse an invalid ISBN.
To test:
[1] Run prove -v t/Koha.t. The last test should fail.
[2] Apply the main patch for this bug.
[3] Run prove -v t/Koha.t again. This time, the test
should pass.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Test Plan:
1) Catalog a record with the ISBN "0394502884 (Random House)"
2) Export the record, edit it so the ISBN is now
"0394502884 (UnRandomHouse)"
3) Using the record import tool, import this record with matching
on ISBN.
4) You should not find a match
5) Apply this patch
6) Run updatedatabase.pl
7) Enable the new system preference AggressiveMatchOnISBN
8) Repeat step 3
9) The tool should now find a match
Signed-off-by: Tom McMurdo <thomas.mcmurdo@state.vp.us>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Added some tests against the methods added by this patch.
To test, prove -v
- t/Koha.t
- t/ReportsGuided.t
Edit: fixed the amount of tests in the skip block. Tests fail for people having earlier versions of DBD::Mock.
Sponsored-by: Universidad Nacional de Córdoba
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works quite nicely!
All tests and QA script pass.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Squashed commit of the following:
commit 146d14665c52edaa85e38b70aabc9d52be5d64b6
Author: Zach Sim <joseph.zachariah.sim@gmail.com>
Date: Mon Jan 17 16:07:24 2011 +1300
Edited DisplayISBN to cleanup the ISBN using _isbn_cleanup if it is not 13 or 10 digits long.
commit ba97b26d9a25470b0717cdd60a3d4f7a5c459ca9
Author: Zach Sim <joseph.zachariah.sim@gmail.com>
Date: Mon Jan 17 16:06:14 2011 +1300
Added extra unit tests to test C4::Koha::DisplayISBN.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
<, >, ', or " in an item call number will no longer make
the bib displays break when using XSLT mode.
Added a new routine to C4::Koha, xml_escape(), to implement
converting &, <, >, ', and " to their corresponding
entities.
Patch loosely based on work done by Daniel Latrémolière <daniel.latremoliere@bulac.fr>
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Input.t was replaced because it tested a now obsolete function.
Input.pm has that function commented out.
Several files were renamed to match their counterparts or
correct misspellingz.
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>