get_string_ajax() doesn't work properly with arguments

Bug #1499583 reported by Jono M
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Jono M
15.10
Fix Released
Undecided
Unassigned

Bug Description

When getting a string with AJAX, arguments to be substituted into the string are passed to the server and are substituted before the response is sent back. This causes problems when a string is used twice with different arguments - the response with the first arguments substituted is cached, and is reused the second time (therefore ignoring the second set of arguments).

It would be much more robust to return a string from the server with "%s"s intact so that interpolation can happen each time it is used on the client.

Revision history for this message
Jono M (jonom) wrote :

One way to verify this: in Firebug (or whatever) enter "get_string_ajax('deletespecific', 'mahara', '1')" then a few seconds later enter "get_string_ajax('deletespecific', 'mahara', '2')". The output from the second command should be "Delete "2"" but is "Delete "1""

Changed in mahara:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Jono Mingard (mingard)
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/5368

Jono M (jonom)
Changed in mahara:
status: Confirmed → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5368
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/897b987a18f121a3f99a1a7e5217e3e325a751b5
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 897b987a18f121a3f99a1a7e5217e3e325a751b5
Author: Jono Mingard <email address hidden>
Date: Fri Sep 25 15:03:27 2015 +1200

Allow repeated use of get_string_ajax with arguments (Bug #1499583)

Return a raw string instead of a formatted one when requested with
AJAX.

behatnotneeded

Change-Id: Ie6711e14b85b79888013e4621c01e2f8fdf3f34a

Robert Lyon (robertl-9)
Changed in mahara:
milestone: none → 15.10.0
status: In Progress → Fix Committed
Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.