Skip to content

Commit 945ea26

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents b5cd0d5 + 66e0061 commit 945ea26

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

system/CLI/CLI.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ public static function table(array $tbody, array $thead = [])
10601060
}
10611061

10621062
$table = '';
1063+
$cols = '';
10631064

10641065
// Joins columns and append the well formatted rows to the table
10651066
for ($row = 0; $row < $totalRows; $row++) {

system/HTTP/IncomingRequest.php

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,16 @@ public function __construct($config, ?URI $uri = null, $body = 'php://input', ?U
154154
throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
155155
}
156156

157-
// Get our body from php://input
158-
if ($body === 'php://input') {
157+
$this->populateHeaders();
158+
159+
if (
160+
$body === 'php://input'
161+
// php://input is not available with enctype="multipart/form-data".
162+
// See https://www.php.net/manual/en/wrappers.php.php#wrappers.php.input
163+
&& strpos($this->getHeaderLine('Content-Type'), 'multipart/form-data') === false
164+
&& (int) $this->getHeaderLine('Content-Length') <= $this->getPostMaxSize()
165+
) {
166+
// Get our body from php://input
159167
$body = file_get_contents('php://input');
160168
}
161169

@@ -167,11 +175,34 @@ public function __construct($config, ?URI $uri = null, $body = 'php://input', ?U
167175

168176
parent::__construct($config);
169177

170-
$this->populateHeaders();
171178
$this->detectURI($config->uriProtocol, $config->baseURL);
172179
$this->detectLocale($config);
173180
}
174181

182+
private function getPostMaxSize(): int
183+
{
184+
$postMaxSize = ini_get('post_max_size');
185+
186+
switch (strtoupper(substr($postMaxSize, -1))) {
187+
case 'G':
188+
$postMaxSize = (int) str_replace('G', '', $postMaxSize) * 1024 ** 3;
189+
break;
190+
191+
case 'M':
192+
$postMaxSize = (int) str_replace('M', '', $postMaxSize) * 1024 ** 2;
193+
break;
194+
195+
case 'K':
196+
$postMaxSize = (int) str_replace('K', '', $postMaxSize) * 1024;
197+
break;
198+
199+
default:
200+
$postMaxSize = (int) $postMaxSize;
201+
}
202+
203+
return $postMaxSize;
204+
}
205+
175206
/**
176207
* Handles setting up the locale, perhaps auto-detecting through
177208
* content negotiation.

system/RESTful/ResourceController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function edit($id = null)
7878
/**
7979
* Add or update a model resource, from "posted" properties
8080
*
81-
* @param string|null|int$id
81+
* @param int|string|null $id
8282
*
8383
* @return ResponseInterface|string|void
8484
*/
@@ -102,6 +102,8 @@ public function delete($id = null)
102102
/**
103103
* Set/change the expected response representation for returned objects
104104
*
105+
* @param string $format json/xml
106+
*
105107
* @return void
106108
*/
107109
public function setFormat(string $format = 'json')

0 commit comments

Comments
 (0)