You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/06/04 11:19:17 UTC

svn commit: r663039 - /incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php

Author: chabotc
Date: Wed Jun  4 02:19:17 2008
New Revision: 663039

URL: http://svn.apache.org/viewvc?rev=663039&view=rev
Log:
SHINDIG-332 removes double json decoding where once is enough

Modified:
    incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php

Modified: incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php?rev=663039&r1=663038&r2=663039&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php (original)
+++ incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php Wed Jun  4 02:19:17 2008
@@ -74,20 +74,20 @@
 			if (get_magic_quotes_gpc()) {
 				$requestParam = stripslashes($requestParam);
 			}
-			$request = json_decode($requestParam, true);
-			if ($request == $requestParam) {
+			$requests = json_decode($requestParam, true);
+			if ($requests == $requestParam) {
 				// oddly enough if the json_decode function can't parse the code,
 				// it just returns the original string (instead of something usefull like 'null' or false :))
 				throw new Exception("Invalid request JSON");
 			}
-			$response = new DataResponse($this->createResponse($requestParam, $token));
+			$response = new DataResponse($this->createResponse($requests, $token));
 		} catch (Exception $e) {
 			$response = new DataResponse(false, BAD_REQUEST);
 		}
 		echo json_encode($response);
 	}
 
-	private function createResponse($requestParam, $token)
+	private function createResponse($requests, $token)
 	{
 		if (empty($token)) {
 			throw new Exception("INVALID_GADGET_TOKEN");
@@ -97,12 +97,6 @@
 		//FIXME currently don't have a propper token, impliment and re-enable this asap
 		$securityToken = $gadgetSigner->createToken($token);
 		$responseItems = array();
-		$requests = json_decode($requestParam, true);
-		if ($requests == $requestParam) {
-			// oddly enough if the json_decode function can't parse the code,
-			// it just returns the original string
-			throw new Exception("Invalid request JSON");
-		}
 		foreach ($requests as $request) {
 			$requestItem = new RequestItem($request['type'], $request, $securityToken);
 			$response = new ResponseItem(NOT_IMPLEMENTED, $request['type'] . " has not been implemented yet.", array());