From 25e67de2a1663bdd66e80e41326eb330aa6feebd Mon Sep 17 00:00:00 2001 From: tenzap Date: Fri, 4 Aug 2023 08:47:12 +0200 Subject: [PATCH 1/2] update to upstream's RestController 3.1.5 --- application/plugins/rest_api/CREDITS | 2 +- .../plugins/rest_api/libraries/Format.php | 7 ++++-- .../rest_api/libraries/RestController.php | 24 +++++++------------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/application/plugins/rest_api/CREDITS b/application/plugins/rest_api/CREDITS index e9e68daf..e79c3637 100644 --- a/application/plugins/rest_api/CREDITS +++ b/application/plugins/rest_api/CREDITS @@ -1,2 +1,2 @@ -CodeIgniter Rest Server v3.1.4 +CodeIgniter Rest Server v3.1.5 diff --git a/application/plugins/rest_api/libraries/Format.php b/application/plugins/rest_api/libraries/Format.php index dc8772ad..54dc4c46 100644 --- a/application/plugins/rest_api/libraries/Format.php +++ b/application/plugins/rest_api/libraries/Format.php @@ -1,5 +1,9 @@ $value) { - //change false/true to 0/1 if (is_bool($value)) { $value = (int) $value; diff --git a/application/plugins/rest_api/libraries/RestController.php b/application/plugins/rest_api/libraries/RestController.php index 8c7d3869..09f37163 100644 --- a/application/plugins/rest_api/libraries/RestController.php +++ b/application/plugins/rest_api/libraries/RestController.php @@ -1,12 +1,12 @@ _enable_xss = ($this->config->item('global_xss_filtering') === true); @@ -270,9 +266,7 @@ public function __construct($config = 'rest') $this->output->parse_exec_vars = false; // Load the rest.php configuration file - $this->load->add_package_path(APPPATH.'plugins/rest_api', false); - $this->load->config($config, false); - $this->load->remove_package_path(APPPATH.'plugins/rest_api', false); + $this->get_local_config($config); // Log the loading time to the log table if ($this->config->item('rest_enable_logging') === true) { @@ -703,7 +697,7 @@ public function response($data = null, $http_code = null, $continue = false) } } ob_end_flush(); - // Otherwise dump the output automatically + // Otherwise dump the output automatically } else { echo json_encode($data); } @@ -872,13 +866,13 @@ protected function _detect_api_key() $this->rest->ignore_limits = false; // Find the key from server or arguments - if (($key = isset($this->_args[$api_key_variable]) ? $this->_args[$api_key_variable] : $this->input->server($key_name))) { + if ($key = isset($this->_args[$api_key_variable]) ? $this->_args[$api_key_variable] : $this->input->server($key_name)) { + $this->rest->key = $key; + if (!($row = $this->rest->db->where($this->config->item('rest_key_column'), $key)->get($this->config->item('rest_keys_table'))->row())) { return false; } - $this->rest->key = $row->{$this->config->item('rest_key_column')}; - isset($row->user_id) && $this->rest->user_id = $row->user_id; isset($row->level) && $this->rest->level = $row->level; isset($row->ignore_limits) && $this->rest->ignore_limits = $row->ignore_limits; From 7a3037df3264f32b0275007d8fc8bb0eadcb8e07 Mon Sep 17 00:00:00 2001 From: tenzap Date: Tue, 20 Jun 2023 10:28:40 +0200 Subject: [PATCH 2/2] rest_api plugin: patch upstream's RestController to work with Kalkun --- .../plugins/rest_api/libraries/Format.php | 4 ---- .../rest_api/libraries/RestController.php | 16 +++++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/application/plugins/rest_api/libraries/Format.php b/application/plugins/rest_api/libraries/Format.php index 54dc4c46..153d8bf6 100644 --- a/application/plugins/rest_api/libraries/Format.php +++ b/application/plugins/rest_api/libraries/Format.php @@ -1,9 +1,5 @@ _enable_xss = ($this->config->item('global_xss_filtering') === true); @@ -266,7 +270,9 @@ public function __construct($config = 'rest') $this->output->parse_exec_vars = false; // Load the rest.php configuration file - $this->get_local_config($config); + $this->load->add_package_path(APPPATH.'plugins/rest_api', false); + $this->load->config($config, false); + $this->load->remove_package_path(APPPATH.'plugins/rest_api', false); // Log the loading time to the log table if ($this->config->item('rest_enable_logging') === true) {