Bug 22583

Summary: Clicking on 'spent' amounts on acqui-home.pl causes internal server error.
Product: Koha Reporter: Barton Chittenden <barton>
Component: AcquisitionsAssignee: Bugs List <koha-bugs>
Status: CLOSED INVALID QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: nick
Version: 18.05   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Crowdfunding committed: 0
Crowdfunding contact: Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Barton Chittenden 2019-03-26 20:27:43 UTC
This is not a problem in master.

To replicate: 
1) Go to Home > Acquisitions
2) Click on an amount in the 'Spent' column. This will trigger an internal server error with the following error in the logs:

DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM (aqorders, aqbasket)
LEFT JOIN biblio ON
    biblio.biblionumber=aqorders.b' at line 14 [for Statement "SELECT
    aqorders.biblionumber, aqorders.basketno, aqorders.ordernumber,
    quantity-quantityreceived AS tleft,
    budgetdate, entrydate,
    aqbasket.booksellerid,
    itype,
    title,
    aqorders.invoiceid,
    aqinvoices.invoicenumber,
    quantityreceived,
    unitprice_tax_included,
    datereceived,
    aqbooksellers.name as vendorname,
    tax_rate_on_receiving,
FROM (aqorders, aqbasket)
LEFT JOIN biblio ON
    biblio.biblionumber=aqorders.biblionumber
LEFT JOIN aqorders_items ON
    aqorders.ordernumber = aqorders_items.ordernumber
LEFT JOIN items ON
    aqorders_items.itemnumber = items.itemnumber
LEFT JOIN aqinvoices ON
    aqorders.invoiceid = aqinvoices.invoiceid
LEFT JOIN aqbooksellers ON
    aqbasket.booksellerid = aqbooksellers.id
WHERE
    aqorders.basketno=aqbasket.basketno AND
    budget_id=? AND
    (datecancellationprinted IS NULL OR
        datecancellationprinted='0000-00-00') AND
    datereceived IS NOT NULL
    GROUP BY aqorders.ordernumber
" with ParamValues: 0="51"] at /usr/share/koha/intranet/cgi-bin/acqui/spent.pl line 89.
An error occurred fetching records: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM (aqorders, aqbasket)
LEFT JOIN biblio ON
    biblio.biblionumber=aqorders.b' at line 14 at /usr/share/koha/intranet/cgi-bin/acqui/spent.pl line 91.
Comment 1 Nick Clemens (kidclamp) 2019-03-26 20:35:59 UTC
caused by custom code on one of our branches