Skip to content

Commit

Permalink
Use POST instead of GET when saving order
Browse files Browse the repository at this point in the history
When the pagination is disabled or quite large, issuing a GET request
would return a 500 because the fieldid value could not be read by PHP,
since the url with all the parameters was too long.

Changing to a POST requet is a better option and can accept more data.
  • Loading branch information
nitriques committed Jul 29, 2016
1 parent 9f39474 commit 187496f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions assets/order_entries.publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if (table.find('.order-entries-item').length > 0){
startValue = parseInt(table.find('.order-entries-item').eq(0).text(),10);
} else {
startValue = parseInt(table.find('tbody tr').eq(0).data('order'),10);
startValue = parseInt(table.find('tbody tr').eq(0).data('order'),10);
}
var assumedStartValue = Symphony.Context.get('env').pagination['max-rows'] * (Symphony.Context.get('env').pagination['current'] - 1) + 1;
if (startValue == 0 || direction == 'asc' && startValue < assumedStartValue) {
Expand All @@ -65,13 +65,13 @@
// Store sort order
if(oldSorting != newSorting) {
$.ajax({
type: 'GET',
type: 'POST',
url: Symphony.Context.get('symphony') + '/extension/order_entries/save/',
data: newSorting + '&field=' + fieldId + filters + '&' + Symphony.Utilities.getXSRF(true),
success: function() {
oldSorting = newSorting;

// Update indexes
// Update indexes
var items = table.find('tbody tr');
items.each(function(index) {
if(direction == 'asc') {
Expand Down
6 changes: 3 additions & 3 deletions content/content.save.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Class contentExtensionOrder_entriesSave extends JSONPage{

public function view(){
$field_id = General::sanitize($_GET['field']);
$items = $_GET['items'];
$filters = $_GET['filters'];
$field_id = General::sanitize($_POST['field']);
$items = $_POST['items'];
$filters = $_POST['filters'];

if(!is_array($items) || empty($items)) {
$this->_Result['error'] = __('No items provided');
Expand Down

0 comments on commit 187496f

Please sign in to comment.