From: Roland Haeder Date: Wed, 29 Apr 2015 09:00:03 +0000 (+0200) Subject: Serializing data to a JSON array string is much faster than using serialize(). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ae931e7f9bd1785c8fd32e5b36a9c5688744ea63;p=hub.git Serializing data to a JSON array string is much faster than using serialize(). Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php index dfd98384c..128dbc300 100644 --- a/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php +++ b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php @@ -67,7 +67,7 @@ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); // Save node list - $nodeList = unserialize(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); + $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); // Make sure it is completely decoded assert(is_array($nodeList)); diff --git a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index 54500de6a..35b609e4c 100644 --- a/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/main/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -180,7 +180,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl assert(count($nodeList) > 0); // Set it in configuration - $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(serialize($nodeList))); + $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList))); } /** diff --git a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php index 442f69e22..92cc25eac 100644 --- a/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -143,7 +143,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.'); // Set it serialized in configuration (temporarily) - $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(serialize($nodeList))); + $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList))); // Translate last exception into a status code $statusCode = $this->getTranslatedStatusFromLastException(); diff --git a/application/hub/starter.php b/application/hub/starter.php index 10e194373..6abc2e616 100644 --- a/application/hub/starter.php +++ b/application/hub/starter.php @@ -33,18 +33,18 @@ $app = call_user_func_array( // Some sanity checks if ((empty($app)) || (is_null($app))) { // Something went wrong! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s could not be launched because the helper class %s is not loaded.', $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class') )); } elseif (!is_object($app)) { // No object! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s could not be launched because 'app' is not an object.', $application )); } elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) { // Method not found! - ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s could not be launched because the method %s is missing.', $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method') ));