[Koha-bugs] [Bug 31727] Orphan records in circulation_rules and false positives after attempt to fix values to be empty or zeroes instead of missing

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Oct 11 10:22:39 CEST 2022


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31727

--- Comment #5 from Andrew Nugged <nugged at gmail.com> ---
(I rewrote the ticket description because I lost one table "3" new in master):

On smart-rules.pl (Home > Administration > Circulation and fine rules):
we have 8 tables:

    1. Defining circulation and fine rules for all libraries
       (... for XXX branch, if branch selected)
    2. Default checkout, hold and return policy
       (... for XXX branch, if branch selected)
    3. Default / Waiting hold cancellation policy
       (... for XXX branch, if branch selected)
    4. Checkout, hold policy by patron category 
       (... for XXX branch, if branch selected)
    5. Daily open article requests limit
       (... for XXX branch, if branch selected)
    6. Article request fees
       (... for XXX branch, if branch selected)
    7. Lost item fee refund on return policy
       (... for XXX branch, if branch selected)
    8. Holds policy by item type
       (... for XXX branch, if branch selected)

and with dropdown, we can select rules for "Standard rules for all libraries"
or switch to ANY of the available branches represented by the whole page.

Attempt to fix missing values in Bug 29012 had the atomic update, which filled
up the circulation_rules table with values if ANY combination of
"branch+category+itemtype" was found in the circulation_rules table. This had
false positives for items from above-mentioned table 2..8 when assumed that
only key/value pairs from table 1 should be those which affect the decision to
add or not" new empty or zeroed item.

This made the problem: after this atomic update, we have the circulation_rules
table randomly filled with orphan elements for "table 1" even if no rules in
table 1 for that branch were present in real.

Worse: those orphan items are never shown as rows of real rules for the
operator so not visible.

Bad: those orphan items, for example, "issuelength" of 0 when it has some
BRANCH overlaps ANY rule without branches and discretely changes behavior when
issuing items.

EXAMPLE:
- Open smart-rules.pl and choose in the first dropdown "Select a library : "
some BRANCH_NAME so this page will reload into BRANCH_NAME-targeted mode for
the whole page.
- Edit the second table "Default checkout, hold and return policy for
BRANCH_NAME" making value holdallowed to be set into something, and save it.
You will see / still have "table 1" empty. At this time key/value pair will be
added to the database for this BRANCH_NAME, and this is exactly what later will
mislead that atomic update:
- make the atomic update from Bug 29012 to fill those "zeroes and empties"
- check the smart-rules.pl page for BRANCH_NAME-targeted mode: there will still
be no rules in the 1st, "Defining circulation and fine rules for XXX branch"
table,
- but now check the database in raw mode: you will see that there will be a
record: BRANCH_NAME will have, for example, "issuelength" of 0 key/value pair.
- OUCH!


What to fix:

Now we need to invent a new atomic update to be applied after this one (and
this is very non-trivial because we somehow need to preserve other proper
values), to fix the database from orphan values. This anyway can lead to very
unpredictable results.

Another thing to consider is that we should even if unsure what is orphans - is
to reveal all hidden values, i.e. append and populate other values to make a
"full row" appear for the operator in the interface, so at least human can SEE
wrong with those rules and then decide/delete but make impossible to have
"remnants" and orphans hidden.

PROBLEM 2:

   unseen_renewals_allowed
vs
   unseenrenewalsallowed

(sic!)

we have 'unseen_renewals_allowed' everywhere in the codebase, except in this
atomic update we have 'unseenrenewalsallowed'. And now DB is polluted even more
:).
This also should be fixed - and more: we might now have unseen_renewals_allowed
and unseenrenewalsallowed both in database.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list