Bug 14327 - Fix js error "TypeError: events is null" in additem.js
Summary: Fix js error "TypeError: events is null" in additem.js
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-04 07:11 UTC by Marcel de Rooy
Modified: 2016-12-05 21:22 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 14327: Fix js error "TypeError: events is null" in additem.js (1.99 KB, patch)
2015-06-04 07:30 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 14327: Fix js error "TypeError: events is null" in additem.js (2.02 KB, patch)
2015-06-04 08:37 UTC, Jonathan Druart
Details | Diff | Splinter Review
[PASSED QA] Bug 14327: Fix js error "TypeError: events is null" in additem.js (2.08 KB, patch)
2015-06-06 17:07 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2015-06-04 07:11:26 UTC
As reported by Jonathan on report 10480:

I found a bug:
1/ Open the console
2/ Go on the new order page
3/ TypeError: events is null
for(i=0; i<events.length; i++) {
additem.js (ligne 176, col. 13)

I suppose it happens when none of the fields use a plugin.

Patch forthcoming.
Comment 1 Marcel de Rooy 2015-06-04 07:30:02 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-06-04 08:37:05 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2015-06-06 17:07:41 UTC
Created attachment 39943 [details] [review]
[PASSED QA] Bug 14327: Fix js error "TypeError: events is null" in additem.js

If you have no item plugins, the events variable in BindPluginEvents
of additem.js will be null. So testing events.length will generate
the described error.
This patch adds a check to prevent that from happening again.

Test plan:
[1] Do not yet apply this patch !
[2] Temporarily remove framework plugins from your items (in ACQ or default
    framework). Probably you have to clear dateaccessioned.pl and
    barcode.pl.
[3] Open js console in your browser.
[4] Go to Acquisition. Open a basket and add an order from a new empty
    record.
[5] You should see js error: "TypeError: events is null" (additem.js:176)
[6] Apply this patch and reload the page (make sure that you refresh so
    that the new javascript code is read).
[7] The TypeError should be gone.
[8] Restore the framework plugins from step 2. Refresh the page again and
    verify that they still work as expected.

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Tomás Cohen Arazi 2015-06-07 22:03:33 UTC
Patch pushed to master.

Thanks Marcel!
Comment 5 Chris Cormack 2015-06-08 03:03:47 UTC
Pushed to 3.20.x will be in 3.20.1
Comment 6 Liz Rea 2015-06-22 22:43:03 UTC
Patch pushed to 3.18.x will be in 3.18.08
Comment 7 Mason James 2015-07-25 10:15:52 UTC
Patch not applicable for 3.16.x series