Javascript warnings from select2, on tagged blog entries block

Bug #1557896 reported by Aaron Wells on 2016-03-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Low
Unassigned
15.10
Low
Unassigned

Bug Description

When you click into the select2 on the tagged blog entries block, but haven't typed anything in yet, Select2 prints a Javascript warning to the JS console.

This is because, in this case, select2 requests taggedposts.json.php without the "q" param that represents a query string. And taggedposts.json.php tries to retrieve the value of q using "param_variable()" without a default value, which means that q is required to be present. When it's not, the script errors out and returns a JSON object with an error message. This is different from what Select2 expects, and Select2 doesn't try to check for it at all, so it throws a warning when it tries to access a field in the object which is not present.

Since this is standard Select2 behavior, we should make it return a non-error value when "q" is empty.

Reviewed: https://reviews.mahara.org/6146
Committed: https://git.mahara.org/mahara/mahara/commit/28fcc277b384c8e1cf25f34399834a18366e3bee
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 28fcc277b384c8e1cf25f34399834a18366e3bee
Author: Aaron Wells <email address hidden>
Date: Wed Mar 16 19:46:15 2016 +1300

Silence error messages from tagged journal entries ajax script

Bug 1557896: When you first click in Select2, it fires off an
aqax request with no "q" value (because there's no query string
yet). We return a "required parameter missing" error message in
a JSON object, which causes a Javascript warning in the browser.

Better to just treat it like an empty q, instead of a missing q.

behatnotneeded - unable to test for issues in console

Change-Id: I81c4cfe77c51fce735cfd2628aaed1e40cc35940

Reviewed: https://reviews.mahara.org/6205
Committed: https://git.mahara.org/mahara/mahara/commit/2bd84453159cdb65a7c20470b3adf7564c0053d6
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.10_STABLE

commit 2bd84453159cdb65a7c20470b3adf7564c0053d6
Author: Aaron Wells <email address hidden>
Date: Wed Mar 16 19:46:15 2016 +1300

Silence error messages from tagged journal entries ajax script

Bug 1557896: When you first click in Select2, it fires off an
aqax request with no "q" value (because there's no query string
yet). We return a "required parameter missing" error message in
a JSON object, which causes a Javascript warning in the browser.

Better to just treat it like an empty q, instead of a missing q.

behatnotneeded - unable to test for issues in console

Change-Id: I81c4cfe77c51fce735cfd2628aaed1e40cc35940
(cherry picked from commit 28fcc277b384c8e1cf25f34399834a18366e3bee)

no longer affects: mahara/16.04
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers