Start early in the day, when you are feeling hopeful.
Test:
--------------To demonstrate bug:
a) created a new VM with 3.8.5 dependencies loaded with koha-common
b) created kohaclone
c) git checkout -b bug8253_36x origin/3.6.x
d) perl Makefile.pl with dev install
( mysqladmin -uroot -p create koha, with user/pass = koha, grants/flush )
e) make; make install
f) adjust install for web/staff access
g) stepped through web installer to initialize fresh database (installer updatedatabase.pl happens)
h) created a "student" patron stud1
i) cataloged a couple of books with z3950 search ( barcode 111 and 222 resprectively)
j) configured circulation rules to charge $1.50 for each day overdue
(Home ? Administration ? Circulation and Fine Rules )
( All, All, 10, 10, blank, 1.50,1,0,0,0,0 click add )
k) configured overdue notice/status triggers (1st 1 day, 2nd 2 days) for "student" "Overdue Notice"
( Home ? Tools ? Notice Triggers)
l) configured finesmode in syspref with "calculate & charge"
m) checked out one book with duedate 1 day in past for patron stud1 barcode 111
n) checked out other book with duedate 2 day in past for patron stud1 barcode 222
o) used mysql to "select * from accountlines;" to see what fines exist
(no dupes just rental charges, 2 $5.00 entries )
p) run misc/cronjobs/fines.pl
q) used mysql to "select * from accountlines;" to see what fines exist
(no dupes just two additional entries for our two overdue books)
r) brought in new kohaclone
s) git checkout -b bug8253_38x origin/3.8.x
t) performed steps d (except no new db to create though) thru step g (new version of updatedatabase.pl)
u) used mysql to "select * from accountlines;" to see what fines exist (no dupes)
v) run misc/cronjobs/fines.pl
w) used mysql to "select * from accountlines;" to see what fines exist (DUPES) - bug 8253
--------------To test bug fix:
y) do the same as above (with a fresh new mysql DB) but after step s)
apply the patch: git am -i -u -3 <thepatch>
and proceed with steps t [BE SURE TO APPLY d-g] and then continue with steps u thru v
z) used mysql to "select * from accountlines;" to see what fines exist (no dupes) - TEST PASSES
Note: You can't reuse the database because it won't be upgraded. :)
Note: Patch assumes F/FU accountlines will not already have ' 23:59' on the end, but this patch only addresses
the folks who upgrade, not the ones who already upgraded. There is another bug fix script for that.
Note: A variation on this test, if you can, is to create a fine that hass accounttype='F', since I only had 'FU'
AFTER STEP
mysql> select * from accountlines;
+----------------+-----------+------------+------------+----------+-------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| borrowernumber | accountno | itemnumber | date | amount | description | dispute | accounttype | amountoutstanding | lastincrement | timestamp | notify_id | notify_level | note | manager_id |
+----------------+-----------+------------+------------+----------+-------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| 51 | 1 | 1 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:01 | 0 | 0 | NULL | 0 |
| 51 | 2 | 2 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:27 | 0 | 0 | NULL | 0 |
+----------------+-----------+------------+------------+----------+-------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
2 rows in set (0.00 sec)
mysql> select * from accountlines;
+----------------+-----------+------------+------------+----------+----------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| borrowernumber | accountno | itemnumber | date | amount | description | dispute | accounttype | amountoutstanding | lastincrement | timestamp | notify_id | notify_level | note | manager_id |
+----------------+-----------+------------+------------+----------+----------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| 51 | 1 | 1 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:01 | 0 | 0 | NULL | 0 |
| 51 | 2 | 2 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:27 | 0 | 0 | NULL | 0 |
| 51 | 3 | 1 | 2012-10-03 | 1.500000 | The hobbit 10/02/2012 | NULL | FU | 1.500000 | 1.500000 | 2012-10-03 14:13:30 | 0 | 0 | NULL | NULL |
| 51 | 4 | 2 | 2012-10-03 | 3.000000 | The Hobbit and philosophy : 10/01/2012 | NULL | FU | 3.000000 | 3.000000 | 2012-10-03 14:13:30 | 0 | 0 | NULL | NULL |
+----------------+-----------+------------+------------+----------+----------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
4 rows in set (0.00 sec)
===============================================================
UPON 3.6x to 3.8.x webinstallker upgrade i got lots of duplicate entry errors, but this was special:
(probably was always there from before, but unrelated to this bug)
[Wed Oct 3 15:28:52 2012] updatedatabase.pl: DBD::mysql::db do failed: Can't create table 'koha.#sql-53a_11a'
(errno: 121) at /home/koha/kohaclone/installer/data/mysql/updatedatabase.pl line 4776.
[Wed Oct 3 15:28:52 2012] updatedatabase.pl: DBD::mysql::db do failed: Can't create table 'koha.#sql-53a_11a'
(errno: 121) at /home/koha/kohaclone/installer/data/mysql/updatedatabase.pl line 4777.
which was in the ADD CONSTRAINT lines:
$DBversion = "3.07.00.022";
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
$dbh->do("DELETE FROM reviews WHERE biblionumber NOT IN (SELECT biblionumber from biblio)");
$dbh->do("UPDATE reviews SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM
borrowers)");
$dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_2 FOREIGN KEY (`biblionumber`) REFERENCES `bibli
o` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE");
$dbh->do("ALTER TABLE reviews ADD CONSTRAINT reviews_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrow
ers (borrowernumber ) ON UPDATE CASCADE ON DELETE SET NULL");
print "Upgrade to $DBversion done (Bug 7493 - Add constraint linking OPAC comment biblionumber to biblio,
OPAC comment borrowernumber to borrowers.)\n";
SetVersion($DBversion);
}
AFTER UPGRADE AND WEB INSTALLER AND misc/cronjobs/fines.pl we see duplicate fines: !!!!BUG
mysql> select * from accountlines;
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| borrowernumber | accountno | itemnumber | date | amount | description | dispute | accounttype | amountoutstanding | lastincrement | timestamp | notify_id | notify_level | note | manager_id |
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| 51 | 1 | 1 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:01 | 0 | 0 | NULL | 0 |
| 51 | 2 | 2 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 14:10:27 | 0 | 0 | NULL | 0 |
| 51 | 3 | 1 | 2012-10-03 | 1.500000 | The hobbit 10/02/2012 | NULL | FU | 1.500000 | 1.500000 | 2012-10-03 14:13:30 | 0 | 0 | NULL | NULL |
| 51 | 4 | 2 | 2012-10-03 | 3.000000 | The Hobbit and philosophy : 10/01/2012 | NULL | FU | 3.000000 | 3.000000 | 2012-10-03 14:13:30 | 0 | 0 | NULL | NULL |
| 51 | 5 | 1 | 2012-10-03 | 1.500000 | The hobbit 10/02/2012 23:59 | NULL | FU | 1.500000 | 1.500000 | 2012-10-03 15:35:40 | 0 | 0 | NULL | NULL |
| 51 | 6 | 2 | 2012-10-03 | 3.000000 | The Hobbit and philosophy : 10/01/2012 23:59 | NULL | FU | 3.000000 | 3.000000 | 2012-10-03 15:35:40 | 0 | 0 | NULL | NULL |
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
6 rows in set (0.00 sec)
==================================================================
NOW I GET TO same 3.6.x state and apply the patch, then UPGRADE to 3.8.x
AND WEB INSTALLER AND misc/cronjobs/fines.pl
mysql> select * from accountlines;
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| borrowernumber | accountno | itemnumber | date | amount | description | dispute | accounttype | amountoutstanding | lastincrement | timestamp | notify_id | notify_level | note | manager_id |
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
| 51 | 1 | 1 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 16:09:48 | 0 | 0 | NULL | 0 |
| 51 | 2 | 2 | 2012-10-03 | 5.000000 | Rental | NULL | Rent | 5.000000 | NULL | 2012-10-03 16:10:01 | 0 | 0 | NULL | 0 |
| 51 | 3 | 1 | 2012-10-03 | 1.500000 | The hobbit 10/02/2012 23:59 | NULL | FU | 1.500000 | 1.500000 | 2012-10-03 16:31:53 | 0 | 0 | NULL | NULL |
| 51 | 4 | 2 | 2012-10-03 | 3.000000 | The Hobbit and philosophy : 10/01/2012 23:59 | NULL | FU | 3.000000 | 3.000000 | 2012-10-03 16:31:53 | 0 | 0 | NULL | NULL |
+----------------+-----------+------------+------------+----------+----------------------------------------------+---------+-------------+-------------------+---------------+---------------------+-----------+--------------+------+------------+
4 rows in set (0.00 sec)
NO DUPES! TEST PASSES!