EvaF Posted February 2, 2021 Share Posted February 2, 2021 in my plugin are the functions base64_encode () and hash_hmac() neccessary for security verification of third-party API request to check digital signature `hmac-sha256` in the request header. How should i step when get validation error : base64_encode() is forbidden hash_hmac()is forbidden ? the third party request is processed on the backround ( with the initialization-minimum -> require dirname(__FILE__) . '/../../../config/config.inc.php';) For some specific requests shoud be changed order status. But the function $orderhistory->changeIdOrderState contains hooks, that are cought by another plugins. Unfortunatelly - if these plugins used f.e. the usual function Tools::displayPrice, the Exception is invoked: // Exception: // PrestaShop\PrestaShop\Adapter\ContainerFinder->getContainer() // <- ToolsCore::getContextLocale(Object(Context)) // <- Tools::displayPrice(815.2) i have found that within handling Exception this piece of code solves the potential problems (like Tools::displayPrice) of another plugins hooks But - Use of globals is forbidden I know, that I can within handling of exception initialize Locale , but cannot quess if other hooked plugins don't use other function where is appkernel required try { $history = new OrderHistory(); $history->id_order = (int)$id_order; $history->changeIdOrderState($id_status, $id_order); $history->save(); } catch (Exception $e) { try { // global use is forbidden global $kernel; if (!$kernel instanceof \AppKernel) { require_once _PS_ROOT_DIR_ . '/app/AppKernel.php'; $env = (true == _PS_MODE_DEV_) ? 'dev' : 'prod'; $kernel = new \AppKernel($env, _PS_MODE_DEV_); $kernel->boot(); } $history = new OrderHistory(); $history->id_order = (int)$id_order; $history->changeIdOrderState($id_status, $id_order); $history->save(); } catch (Exception $e) { // log error } } Would someone be so kind and give me advice how to step?? Link to comment Share on other sites More sharing options...
arvistar Posted January 6, 2023 Share Posted January 6, 2023 This question is also relevant for me. Does anyone have any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now