From 9df68b530753f16c13e36b90ac47ca7423797afe Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Mon, 23 Apr 2012 12:34:16 -0400 Subject: [PATCH] BUG 8973 "Replace all instances of json_encode() and json_decode()..." SOLVED - Problems with functions json_encode and json_decode in PHP 5.2 - Replace json_encode and json_decode with G::json_encode and G::json_decode --- .../tasks/templates/pluginApplicationAjax.php.tpl | 2 +- .../templates/pluginStepApplicationAjax.php.tpl | 2 +- .../classes/triggers/class.pmAlfrescoFunctions.php | 14 +++++++------- .../triggers/class.pmSharepointFunctions.php | 2 +- .../classes/triggers/class.pmTrSharepoint.php | 8 ++++---- .../engine/classes/triggers/class.pmTrZimbra.php | 8 ++++---- workflow/engine/controllers/adminProxy.php | 6 +++--- .../engine/methods/appFolder/appFolderAjax.php | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gulliver/bin/tasks/templates/pluginApplicationAjax.php.tpl b/gulliver/bin/tasks/templates/pluginApplicationAjax.php.tpl index 1a402722c..a4b45f7e3 100644 --- a/gulliver/bin/tasks/templates/pluginApplicationAjax.php.tpl +++ b/gulliver/bin/tasks/templates/pluginApplicationAjax.php.tpl @@ -27,7 +27,7 @@ try { list($userNum, $user) = userGet($limit, $start); //echo "{success: " . true . ", resultTotal: " . count($user) . ", resultRoot: " . G::json_encode($user) . "}"; - echo json_encode(array("success" => true, "resultTotal" => $userNum, "resultRoot" => $user)); + echo G::json_encode(array("success" => true, "resultTotal" => $userNum, "resultRoot" => $user)); break; } } catch (Exception $e) { diff --git a/gulliver/bin/tasks/templates/pluginStepApplicationAjax.php.tpl b/gulliver/bin/tasks/templates/pluginStepApplicationAjax.php.tpl index d331d3055..daea092d6 100644 --- a/gulliver/bin/tasks/templates/pluginStepApplicationAjax.php.tpl +++ b/gulliver/bin/tasks/templates/pluginStepApplicationAjax.php.tpl @@ -19,7 +19,7 @@ try { } //echo "{success: " . true . ", resultTotal: " . count($aResult) . ", resultRoot: " . G::json_encode($aResult) . "}"; - echo json_encode(array("success" => true, "resultTotal" => count($aResult), "resultRoot" => $aResult)); + echo G::json_encode(array("success" => true, "resultTotal" => count($aResult), "resultRoot" => $aResult)); } catch (Exception $e) { echo null; } diff --git a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php index 7bf736650..f8aa50311 100755 --- a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php +++ b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php @@ -47,7 +47,7 @@ function cancelCheckout($alfrescoServerUrl, $docUid, $user="", $pwd="") { $alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid"; $domapi_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml;type=entry"); //$alfrescoMessage = $domapi_exec['header']; -$domapi_res = json_decode($domapi_exec->getResponse()); +$domapi_res = G::json_decode($domapi_exec->getResponse()); return $domapi_res; } @@ -169,7 +169,7 @@ function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) { $alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId"; $alfresco_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml"); - $alfresco_res = json_decode($alfresco_exec->getResponse()); + $alfresco_res = G::json_decode($alfresco_exec->getResponse()); echo($alfresco_res); return $alfresco_res; } @@ -195,7 +195,7 @@ function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) { function downloadDoc($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd) { $alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId"; $alfresco_exec = RestClient::delete($alfresco,$user,$pwd,"application/atom+xml"); - $alfresco_res = json_decode($alfresco_exec->getResponse()); + $alfresco_res = G::json_decode($alfresco_exec->getResponse()); echo($alfresco_res); return $alfresco_res; } @@ -219,10 +219,10 @@ function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) { $getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout"; $domapi_exec = RestClient::get($getChildrenUrl,$user,$pwd,'application/atom+xml'); - $sXmlArray = json_decode($domapi_exec->getResponse()); + $sXmlArray = G::json_decode($domapi_exec->getResponse()); $sXmlArray = trim($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray); - $aXmlArray = @json_decode(@json_encode($xXmlArray),1); + $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); var_dump($aXmlArray); return $alfresco_res; @@ -250,7 +250,7 @@ function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) { $sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = trim($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray); - $aXmlArray = @json_decode(@json_encode($xXmlArray),1); + $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); //var_dump($aXmlArray); var_dump($aXmlArray); @@ -290,7 +290,7 @@ function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docTy $sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = trim($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray); - $aXmlArray = @json_decode(@json_encode($xXmlArray),1); + $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); var_dump($aXmlArray); return $aXmlArray; } \ No newline at end of file diff --git a/workflow/engine/classes/triggers/class.pmSharepointFunctions.php b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php index 4e5995392..01e8bc4ab 100755 --- a/workflow/engine/classes/triggers/class.pmSharepointFunctions.php +++ b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php @@ -311,7 +311,7 @@ function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname */ $xml = $result->GetVersionsResult->any;// in Result we get string in Xml format $xmlNew = simplexml_load_string($xml);// used to parse string to xml - $xmlArray = @json_decode(@json_encode($xmlNew),1);// used to convert Objects to array + $xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array $resultCount = count($xmlArray['result']); for($i=0;$i<$resultCount;$i++) { diff --git a/workflow/engine/classes/triggers/class.pmTrSharepoint.php b/workflow/engine/classes/triggers/class.pmTrSharepoint.php index f9fb94c45..04589a293 100755 --- a/workflow/engine/classes/triggers/class.pmTrSharepoint.php +++ b/workflow/engine/classes/triggers/class.pmTrSharepoint.php @@ -109,7 +109,7 @@ class pmTrSharepointClass{ $result = $this->dwsObj->callWsMethod($methodName, $paramArray); $xml = $result->CreateDwsResult; // in Result we get string in Xml format $xmlNew = simplexml_load_string($xml); // used to parse string to xml - $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array $dwsUrl = $xmlArray['Url']; return "Dws with following Url is created:$dwsUrl"; @@ -200,7 +200,7 @@ class pmTrSharepointClass{ var_dump($result); $sResult = $result->GetDwsDataResult; /* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml - $xmlArray = @json_decode(@json_encode($xmlNew),1);// used to convert Objects to array */ + $xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array */ $serializeResult = serialize($sResult); // serializing the Array for Returning. var_dump($serializeResult); return $serializeResult; @@ -301,7 +301,7 @@ class pmTrSharepointClass{ if ($result) { $sResult = $result->DeleteVersionResult->any; $xmlNew = simplexml_load_string($sResult); // used to parse string to xml - $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array $versionCount = count($xmlArray['result']); if($versionCount>1) @@ -338,7 +338,7 @@ class pmTrSharepointClass{ if ($result) { $xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format $xmlNew = simplexml_load_string($xml); // used to parse string to xml - $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1); // used to convert Objects to array $latestVersion = $xmlArray['result']['@attributes']['version']; return "All Versions are Deleted, except the latest i.e $latestVersion"; } else { diff --git a/workflow/engine/classes/triggers/class.pmTrZimbra.php b/workflow/engine/classes/triggers/class.pmTrZimbra.php index 23ffc837a..30dccdc05 100644 --- a/workflow/engine/classes/triggers/class.pmTrZimbra.php +++ b/workflow/engine/classes/triggers/class.pmTrZimbra.php @@ -52,7 +52,7 @@ function getZimbraFolder($ServerUrl, $username, $preAuthKey, $folderName) { $aXmlArray = array(); $aXmlArray = $zimbra->getFolder($folderName); - $sXmlArray = @json_decode(@json_encode($aXmlArray), 1); + $sXmlArray = @G::json_decode(@G::json_encode($aXmlArray), 1); $serializeResult = serialize($sXmlArray); // serializing the Array for Returning. return $serializeResult; @@ -84,7 +84,7 @@ function getZimbraContactList($ServerUrl, $username, $preAuthKey) { $sXmlArray = array(); $sXmlArray = $zimbra->getContacts(); - $aXmlArray = @json_decode(@json_encode($sXmlArray), 1); + $aXmlArray = @G::json_decode(@G::json_encode($sXmlArray), 1); $serializeResult = serialize($aXmlArray); // serializing the Array for Returning. return $serializeResult; @@ -119,7 +119,7 @@ function getZimbraTaskList($ServerUrl, $username, $preAuthKey) { $sXmlArray = array(); $sXmlArray = $zimbra->getTasks(); - $aXmlArray = @json_decode(@json_encode($sXmlArray), 1); + $aXmlArray = @G::json_decode(@G::json_encode($sXmlArray), 1); $serializeResult = serialize($aXmlArray); // serializing the Array for Returning. return $serializeResult; @@ -154,7 +154,7 @@ function getZimbraAppointmentList($ServerUrl, $username, $preAuthKey) { $sXmlArray = array(); $sXmlArray = $zimbra->getAppointments(); - $aXmlArray = @json_decode(@json_encode($sXmlArray), 1); + $aXmlArray = @G::json_decode(@G::json_encode($sXmlArray), 1); $serializeResult = serialize($aXmlArray); // serializing the Array for Returning. return $serializeResult; diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index d993acfbc..9fd99a8cb 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -107,7 +107,7 @@ class adminProxy extends HttpProxyController function uxUserUpdate($httpData) { require_once 'classes/model/Users.php'; - $data = json_decode($httpData->users); + $data = G::json_decode($httpData->users); $list = array(); if (!is_array($data)) { @@ -145,7 +145,7 @@ class adminProxy extends HttpProxyController function uxGroupUpdate($httpData) { require_once 'classes/model/Groupwf.php'; - $data = (array) json_decode($httpData->groups); + $data = (array) G::json_decode($httpData->groups); $group = GroupwfPeer::retrieveByPK($data['GRP_UID']); $group->setGrpUx($data['GRP_UX']); @@ -715,7 +715,7 @@ class adminProxy extends HttpProxyController } } $o = array('images' => $images); - echo json_encode($o); + echo G::json_encode($o); exit(); } /** diff --git a/workflow/engine/methods/appFolder/appFolderAjax.php b/workflow/engine/methods/appFolder/appFolderAjax.php index dddcf1dc7..9bbe5f89e 100755 --- a/workflow/engine/methods/appFolder/appFolderAjax.php +++ b/workflow/engine/methods/appFolder/appFolderAjax.php @@ -83,7 +83,7 @@ function getExtJSParams() { function sendJsonResultGeneric($response, $callback) { header("Content-Type: application/json"); - $finalResponse = json_encode($response); + $finalResponse = G::json_encode($response); if ($callback != '') { print $callback . "($finalResponse);"; } else {