diff --git a/app/bootstrap.php b/app/bootstrap.php index dae0af0..b29939d 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -162,12 +162,9 @@ public function subscribe() /** * Have the plugin respond to an event * - * @param string $topic - * @param array $message - * @return void * @throws Exception */ - public function respond($topic, $message) + public function respond(string $topic, Varien_Object $message): void { list($resource, $event) = explode(':', $topic, 2); if ( ! $this->getConfig("plugin/{$this->_plugin}/events/{$resource}/{$event}") && $topic != 'test:ping') { @@ -364,10 +361,10 @@ public function log($message, $destination = NULL) /** * Write exception to log * - * @param Exception $e + * @param Throwable $e * @return void */ - public function logException(Exception $e) + public function logException(Throwable $e) { $this->log("\n" . $e->__toString()); } diff --git a/lib/Varien/Object.php b/lib/Varien/Object.php index 8210709..25b7b20 100644 --- a/lib/Varien/Object.php +++ b/lib/Varien/Object.php @@ -753,6 +753,7 @@ public function debug($data=NULL, &$objects=array()) * @param string $offset * @param mixed $value */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $this->_data[$offset] = $value; @@ -765,6 +766,7 @@ public function offsetSet($offset, $value) * @param string $offset * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->_data[$offset]); @@ -776,6 +778,7 @@ public function offsetExists($offset) * @link http://www.php.net/manual/en/arrayaccess.offsetunset.php * @param string $offset */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->_data[$offset]); @@ -788,6 +791,7 @@ public function offsetUnset($offset) * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->_data[$offset]) ? $this->_data[$offset] : NULL; diff --git a/pub/respond.php b/pub/respond.php index 6898c47..de30f13 100644 --- a/pub/respond.php +++ b/pub/respond.php @@ -39,14 +39,16 @@ if ( ! $message) { throw new Exception('Message not specified.', 400); } + $message = new Varien_Object($message); $middleware->log(sprintf('Received webhook for %s topic with message: %s', $topic, $json), 'webhooks.log'); $middleware->respond($topic, $message); -} catch (Exception $e) { +} catch (Throwable $e) { if (empty($middleware)) { error_log($e->getMessage()); } else { $middleware->logException($e); } http_response_code($e->getCode() ?: 500); + echo "ERROR: {$e->getMessage()}"; }