http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11279

            Bug ID: 11279
           Summary: Quote of the day feature won't pick a quote
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Tools
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
                CC: [email protected]

In order to select a new quote the feature does a count on the quotes table,
then it tries to select an id in that range.

But it can easily happen that you get out of the range with your ids. In my
example I had loaded the English sample file, the library decided to add new
quotes and deleted all samples. So the smallest id in the table ended up to be
around 40, with less than 40 entries total.

We allow deleting entries, there is no way to edit the id.

Code in Koha.pm:
1439     unless ($quote) {        # if there are not matches, choose a random
quote
1440         # get a list of all available quote ids
1441         $sth = C4::Context->dbh->prepare('SELECT count(*) FROM quotes;');
1442         $sth->execute;
1443         my $range = ($sth->fetchrow_array)[0];
1444         if ($range > 1) {
1445             # chose a random id within that range if there is more than
one quote
1446             my $id = int(rand($range));
1447             # grab it
1448             $query = 'SELECT * FROM quotes WHERE id = ?;';
1449             $sth = C4::Context->dbh->prepare($query);
1450             $sth->execute($id);
1451         }

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to