From 06991af115bb5f3e5a1d3eee924cb31896738b1c Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 25 Apr 2014 12:38:36 +0000 Subject: [PATCH] Fix problem with not serial keys and JSON response --- .../Mibew/RequestProcessor/UsersProcessor.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php index 7facf628..7b385a21 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php @@ -327,9 +327,12 @@ class UsersProcessor extends ClientSideProcessor $dispatcher = EventDispatcher::getInstance(); $dispatcher->triggerEvent('usersUpdateThreadsAlter', $arguments); - // Send results back to the client + // Send results back to the client. "array_values" function should be + // used to avoid problems with JSON conversion. If there will be gaps in + // keys (the keys are not serial) JSON Object will be produced instead + // of an Array. return array( - 'threads' => $arguments['threads'], + 'threads' => array_values($arguments['threads']), 'lastRevision' => $revision, ); } @@ -470,8 +473,12 @@ class UsersProcessor extends ClientSideProcessor ); $dispatcher->triggerEvent('usersUpdateVisitorsAlter', $arguments); + // Send results back to the client. "array_values" function should be + // used to avoid problems with JSON conversion. If there will be gaps in + // keys (the keys are not serial) JSON Object will be produced instead + // of an Array. return array( - 'visitors' => $arguments['visitors'], + 'visitors' => array_values($arguments['visitors']), ); }