Skip to content

Commit af3b843

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
2 parents 447cab6 + c08de60 commit af3b843

File tree

16 files changed

+65
-26
lines changed

16 files changed

+65
-26
lines changed

.php-cs-fixer.dist.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
__DIR__ . '/spark',
3939
]);
4040

41-
$overrides = [];
41+
$overrides = [
42+
'no_useless_concat_operator' => [
43+
'juggle_simple_strings' => true,
44+
],
45+
];
4246

4347
$options = [
4448
'cacheFile' => 'build/.php-cs-fixer.cache',

.php-cs-fixer.no-header.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
__DIR__ . '/admin/starter/builds',
3131
]);
3232

33-
$overrides = [];
33+
$overrides = [
34+
'no_useless_concat_operator' => [
35+
'juggle_simple_strings' => true,
36+
],
37+
];
3438

3539
$options = [
3640
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',

.php-cs-fixer.user-guide.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
'php_unit_internal_class' => false,
3434
'no_unused_imports' => false,
3535
'class_attributes_separation' => false,
36+
'no_useless_concat_operator' => [
37+
'juggle_simple_strings' => true,
38+
],
3639
];
3740

3841
$options = [

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ public function unionAll($union)
11921192
*/
11931193
protected function addUnionStatement($union, bool $all = false)
11941194
{
1195-
$this->QBUnion[] = "\n" . 'UNION '
1195+
$this->QBUnion[] = "\nUNION "
11961196
. ($all ? 'ALL ' : '')
11971197
. 'SELECT * FROM '
11981198
. $this->buildSubquery($union, true, 'uwrp' . (count($this->QBUnion) + 1));

system/Database/MySQLi/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public function escapeLikeStringDirect($str)
360360
// Escape LIKE condition wildcards
361361
return str_replace(
362362
[$this->likeEscapeChar, '%', '_'],
363-
['\\' . $this->likeEscapeChar, '\\' . '%', '\\' . '_'],
363+
['\\' . $this->likeEscapeChar, '\\%', '\\_'],
364364
$str
365365
);
366366
}

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r
381381
mkdir(WRITEPATH . 'debugbar', 0777);
382382
}
383383

384-
write_file(WRITEPATH . 'debugbar/' . 'debugbar_' . $time . '.json', $data, 'w+');
384+
write_file(WRITEPATH . 'debugbar/debugbar_' . $time . '.json', $data, 'w+');
385385

386386
$format = $response->getHeaderLine('content-type');
387387

system/HTTP/IncomingRequest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ public function getPost($index = null, $filter = null, $flags = null)
615615
*/
616616
public function getPostGet($index = null, $filter = null, $flags = null)
617617
{
618+
if ($index === null) {
619+
return array_merge($this->getGet($index, $filter, $flags), $this->getPost($index, $filter, $flags));
620+
}
618621
// Use $_POST directly here, since filter_has_var only
619622
// checks the initial POST data, not anything that might
620623
// have been added since.
@@ -632,6 +635,9 @@ public function getPostGet($index = null, $filter = null, $flags = null)
632635
*/
633636
public function getGetPost($index = null, $filter = null, $flags = null)
634637
{
638+
if ($index === null) {
639+
return array_merge($this->getPost($index, $filter, $flags), $this->getGet($index, $filter, $flags));
640+
}
635641
// Use $_GET directly here, since filter_has_var only
636642
// checks the initial GET data, not anything that might
637643
// have been added since.

system/Helpers/form_helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,13 @@ function form_datalist(string $name, string $value, array $options): string
485485

486486
$out = form_input($data) . "\n";
487487

488-
$out .= "<datalist id='" . $name . '_list' . "'>";
488+
$out .= "<datalist id='" . $name . "_list'>";
489489

490490
foreach ($options as $option) {
491-
$out .= "<option value='{$option}'>" . "\n";
491+
$out .= "<option value='{$option}'>\n";
492492
}
493493

494-
return $out . ('</datalist>' . "\n");
494+
return $out . ("</datalist>\n");
495495
}
496496
}
497497

system/View/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected function parsePair(string $variable, array $data, string $template): a
277277
// have something to loop over.
278278
preg_match_all(
279279
'#' . $this->leftDelimiter . '\s*' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '(.+?)' .
280-
$this->leftDelimiter . '\s*' . '/' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '#s',
280+
$this->leftDelimiter . '\s*/' . preg_quote($variable, '#') . '\s*' . $this->rightDelimiter . '#s',
281281
$template,
282282
$matches,
283283
PREG_SET_ORDER

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,26 @@ public function testGetPostEmpty()
569569
$this->assertSame($_GET, $this->request->getGetPost());
570570
}
571571

572+
public function testPostGetSecondStream()
573+
{
574+
$_GET['get'] = '3';
575+
$this->assertSame($_GET, $this->request->getPostGet());
576+
}
577+
578+
public function testGetPostSecondStream()
579+
{
580+
$_POST['post'] = '5';
581+
$this->assertSame($_POST, $this->request->getGetPost());
582+
}
583+
584+
public function testGetPostSecondStreams()
585+
{
586+
$_GET['get'] = '3';
587+
$_POST['post'] = '5';
588+
$this->assertSame(array_merge($_GET, $_POST), $this->request->getPostGet());
589+
$this->assertSame(array_merge($_POST, $_GET), $this->request->getGetPost());
590+
}
591+
572592
public function testWithFalseBody()
573593
{
574594
// Use `false` here to simulate file_get_contents returning a false value

tests/system/HTTP/MessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testAppendBody()
156156

157157
$this->message->appendBody('\n');
158158

159-
$this->assertSame('moo' . '\n', $this->message->getBody());
159+
$this->assertSame('moo\n', $this->message->getBody());
160160
}
161161

162162
public function testSetHeaderReplacingHeader()

tests/system/Images/GDHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function testImageConvert()
413413
public function testImageReorientLandscape()
414414
{
415415
for ($i = 0; $i <= 8; $i++) {
416-
$source = $this->origin . 'EXIFsamples/landscape_' . '' . $i . '.jpg';
416+
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
417417

418418
$this->handler->withFile($source);
419419
$this->handler->reorient();
@@ -429,7 +429,7 @@ public function testImageReorientLandscape()
429429
public function testImageReorientPortrait()
430430
{
431431
for ($i = 0; $i <= 8; $i++) {
432-
$source = $this->origin . 'EXIFsamples/portrait_' . '' . $i . '.jpg';
432+
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
433433

434434
$this->handler->withFile($source);
435435
$this->handler->reorient();

tests/system/Images/ImageMagickHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function testImageConvert()
408408
public function testImageReorientLandscape()
409409
{
410410
for ($i = 0; $i <= 8; $i++) {
411-
$source = $this->origin . 'EXIFsamples/landscape_' . '' . $i . '.jpg';
411+
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
412412
$result = $this->root . 'landscape_' . $i . '_reoriented.jpg';
413413

414414
$this->handler->withFile($source);
@@ -427,7 +427,7 @@ public function testImageReorientLandscape()
427427
public function testImageReorientPortrait()
428428
{
429429
for ($i = 0; $i <= 8; $i++) {
430-
$source = $this->origin . 'EXIFsamples/portrait_' . '' . $i . '.jpg';
430+
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
431431
$result = $this->root . 'portrait_' . $i . '_reoriented.jpg';
432432

433433
$this->handler->withFile($source);

user_guide_src/source/changelogs/v4.2.8.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ none.
3636
Bugs Fixed
3737
**********
3838

39-
none.
39+
- Fixed a bug when the ``CodeIgniter\HTTP\IncomingRequest::getPostGet()`` and ``CodeIgniter\HTTP\IncomingRequest::getGetPost()`` methods didn't return values from the other stream when ``index`` was set to ``null``.
4040

4141
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

user_guide_src/source/incoming/incomingrequest.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ The methods provided by the parent classes that are available are:
339339
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
340340
:param int $flags: Flags to apply. A list of flags can be found
341341
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
342-
:returns: $_POST if no parameters supplied, otherwise the POST value if found, or null if not
342+
:returns: $_POST and $_GET combined if no parameters specified (prefer POST value on conflict),
343+
otherwise looks for POST value, if nothing found looks for GET value, if no value found returns null
343344
:rtype: mixed|null
344345

345346
This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
@@ -348,22 +349,29 @@ The methods provided by the parent classes that are available are:
348349

349350
.. literalinclude:: incomingrequest/032.php
350351

352+
If no index is specified, it will return both POST and GET streams combined.
353+
Although POST data will be preferred in case of name conflict.
354+
351355
.. php:method:: getGetPost([$index = null[, $filter = null[, $flags = null]]])
352356
353357
:param string $index: The name of the variable/key to look for.
354358
:param int $filter: The type of filter to apply. A list of filters can be
355359
found `here <https://www.php.net/manual/en/filter.filters.php>`__.
356360
:param int $flags: Flags to apply. A list of flags can be found
357361
`here <https://www.php.net/manual/en/filter.filters.flags.php>`__.
358-
:returns: $_POST if no parameters supplied, otherwise the POST value if found, or null if not
362+
:returns: $_GET and $_POST combined if no parameters specified (prefer GET value on conflict),
363+
otherwise looks for GET value, if nothing found looks for POST value, if no value found returns null
359364
:rtype: mixed|null
360365

361366
This method works pretty much the same way as ``getPost()`` and ``getGet()``, only combined.
362-
It will search through both POST and GET streams for data, looking first in GET, and
367+
It will search through both GET and POST streams for data, looking first in GET, and
363368
then in POST:
364369

365370
.. literalinclude:: incomingrequest/033.php
366371

372+
If no index is specified, it will return both GET and POST streams combined.
373+
Although GET data will be preferred in case of name conflict.
374+
367375
.. php:method:: getCookie([$index = null[, $filter = null[, $flags = null]]])
368376
:noindex:
369377

user_guide_src/source/testing/benchmark/007.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
$iterator = new \CodeIgniter\Debug\Iterator();
44

5-
// Add a new task
6-
$iterator->add('single_concat', static function () {
7-
$str = 'Some basic' . 'little' . 'string concatenation test.';
8-
});
9-
10-
// Add another task
11-
$iterator->add('double', static function ($a = 'little') {
12-
$str = "Some basic {$little} string test.";
5+
$iterator->add('double', static function ($word = 'little') {
6+
"Some basic {$word} string test.";
137
});

0 commit comments

Comments
 (0)