Skip to content

Commit dbc523f

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: user_guide_src/source/dbmgmt/forge.rst user_guide_src/source/dbmgmt/forge/013.php
2 parents 2ac344f + 76000ab commit dbc523f

File tree

12 files changed

+175
-54
lines changed

12 files changed

+175
-54
lines changed

admin/RELEASE.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Documentation guide based on the releases of `4.0.5` and `4.1.0` on January 31, 2021.
44
>
5-
> Updated for `4.2.3` on August 6, 2022.
5+
> Updated for `4.2.10` on November 5, 2022.
66
>
77
> -MGatner
88
@@ -17,7 +17,7 @@ When generating the changelog each Pull Request to be included must have one of
1717
PRs with breaking changes must have the following additional label:
1818
- **breaking change** ... PRs that may break existing functionalities
1919

20-
To auto-generate, start drafting a new Release and use the "Auto-generate release notes" button.
20+
To auto-generate, start drafting a new Release and use the "Generate release notes" button.
2121
Copy the resulting content into **CHANGELOG.md** and adjust the format to match the existing content.
2222

2323
## Preparation
@@ -43,6 +43,7 @@ git clone [email protected]:codeigniter4/userguide.git
4343
* Set the date in **user_guide_src/source/changelogs/{version}.rst** to format `Release Date: January 31, 2021`
4444
* Create a new changelog for the next version at **user_guide_src/source/changelogs/{next_version}.rst** and add it to **index.rst**
4545
* Create **user_guide_src/source/installation/upgrade_{ver}.rst**, fill in the "All Changes" section, and add it to **upgrading.rst**
46+
* git diff --name-status master -- . ':!system'
4647
* Commit the changes with "Prep for 4.x.x release" and push to origin
4748
* Create a new PR from `release-4.x.x` to `develop`:
4849
* Title: "Prep for 4.x.x release"
@@ -53,12 +54,16 @@ git clone [email protected]:codeigniter4/userguide.git
5354
* Description: blank
5455
* Merge the PR then create a new Release:
5556
* Version: "v4.x.x"
57+
* Target: master
5658
* Title: "CodeIgniter 4.x.x"
5759
* Description:
5860
```
5961
CodeIgniter 4.x.x release.
6062
6163
See the changelog: https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md
64+
65+
## New Contributors
66+
*
6267
```
6368
* Watch for the "Deploy Distributable Repos" action to make sure **framework**, **appstarter**, and **userguide** get updated
6469
* Run the following commands to install and test `appstarter` and verify the new version:
@@ -70,8 +75,15 @@ composer test && composer info codeigniter4/framework
7075
* Verify that the user guide actions succeeded:
7176
* "Deploy Distributable Repos", framework repo
7277
* "Deploy Production", UG repo
73-
* "pages-build-deployment", both repos
78+
* "pages-build-deployment", UG repo
7479
* Fast-forward `develop` branch to catch the merge commit from `master`
80+
```console
81+
git fetch origin
82+
git checkout develop
83+
git merge origin/develop
84+
git merge origin/master
85+
git push origin HEAD
86+
```
7587
* Update the next minor upgrade branch `4.x`:
7688
```console
7789
git fetch origin

admin/next-changelog-minor.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Version {version}
2+
#################
3+
4+
Release Date: Unreleased
5+
6+
**{version} release of CodeIgniter4**
7+
8+
.. contents::
9+
:local:
10+
:depth: 3
11+
12+
Highlights
13+
**********
14+
15+
- TBD
16+
17+
BREAKING
18+
********
19+
20+
Behavior Changes
21+
================
22+
23+
Interface Changes
24+
=================
25+
26+
Method Signature Changes
27+
========================
28+
29+
Enhancements
30+
************
31+
32+
Commands
33+
========
34+
35+
Testing
36+
=======
37+
38+
Database
39+
========
40+
41+
Query Builder
42+
-------------
43+
44+
Forge
45+
-----
46+
47+
Others
48+
------
49+
50+
Model
51+
=====
52+
53+
Libraries
54+
=========
55+
56+
Helpers and Functions
57+
=====================
58+
59+
Others
60+
======
61+
62+
Message Changes
63+
***************
64+
65+
Changes
66+
*******
67+
68+
Deprecations
69+
************
70+
71+
Bugs Fixed
72+
**********
73+
74+
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

admin/next-changelog-patch.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Version {version}
2+
#################
3+
4+
Release Date: Unreleased
5+
6+
**{version} release of CodeIgniter4**
7+
8+
.. contents::
9+
:local:
10+
:depth: 3
11+
12+
BREAKING
13+
********
14+
15+
Enhancements
16+
************
17+
18+
Message Changes
19+
***************
20+
21+
Changes
22+
*******
23+
24+
Deprecations
25+
************
26+
27+
Bugs Fixed
28+
**********
29+
30+
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

admin/next.rst

Lines changed: 0 additions & 14 deletions
This file was deleted.

system/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ protected function doProtectFields(array $data): array
12541254
*/
12551255
protected function setDate(?int $userData = null)
12561256
{
1257-
$currentDate = $userData ?? time();
1257+
$currentDate = $userData ?? Time::now()->getTimestamp();
12581258

12591259
return $this->intToDate($currentDate);
12601260
}

system/HTTP/RequestTrait.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ public function getIPAddress(): string
6767
$this->ipAddress = $this->getServer('REMOTE_ADDR');
6868

6969
if ($proxyIPs) {
70-
foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP'] as $header) {
71-
if (($spoof = $this->getServer($header)) !== null) {
70+
foreach (['x-forwarded-for', 'client-ip', 'x-client-ip', 'x-cluster-client-ip'] as $header) {
71+
$spoof = null;
72+
$headerObj = $this->header($header);
73+
74+
if ($headerObj !== null) {
75+
$spoof = $headerObj->getValue();
76+
7277
// Some proxies typically list the whole chain of IP
7378
// addresses through which the client has reached us.
7479
// e.g. client_ip, proxy_ip1, proxy_ip2, etc.

tests/system/HTTP/IncomingRequestTest.php

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,10 @@ public function testGetIPAddressNormal()
706706
{
707707
$expected = '123.123.123.123';
708708
$_SERVER['REMOTE_ADDR'] = $expected;
709-
$this->request = new Request(new App());
709+
710+
$this->request = new Request(new App());
711+
$this->request->populateHeaders();
712+
710713
$this->assertSame($expected, $this->request->getIPAddress());
711714
// call a second time to exercise the initial conditional block in getIPAddress()
712715
$this->assertSame($expected, $this->request->getIPAddress());
@@ -715,66 +718,75 @@ public function testGetIPAddressNormal()
715718
public function testGetIPAddressThruProxy()
716719
{
717720
$expected = '123.123.123.123';
721+
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
718722
$_SERVER['REMOTE_ADDR'] = '10.0.1.200';
719723
$config = new App();
720724
$config->proxyIPs = '10.0.1.200,192.168.5.0/24';
721-
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
722-
$this->request = new Request($config);
725+
726+
$this->request = new Request($config);
727+
$this->request->populateHeaders();
723728

724729
// we should see the original forwarded address
725730
$this->assertSame($expected, $this->request->getIPAddress());
726731
}
727732

728733
public function testGetIPAddressThruProxyInvalid()
729734
{
730-
$expected = '123.456.23.123';
731-
$_SERVER['REMOTE_ADDR'] = '10.0.1.200';
735+
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.456.23.123';
736+
$expected = '10.0.1.200';
737+
$_SERVER['REMOTE_ADDR'] = $expected;
732738
$config = new App();
733739
$config->proxyIPs = '10.0.1.200,192.168.5.0/24';
734-
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
735-
$this->request = new Request($config);
740+
741+
$this->request = new Request($config);
742+
$this->request->populateHeaders();
736743

737744
// spoofed address invalid
738-
$this->assertSame('10.0.1.200', $this->request->getIPAddress());
745+
$this->assertSame($expected, $this->request->getIPAddress());
739746
}
740747

741748
public function testGetIPAddressThruProxyNotWhitelisted()
742749
{
743-
$expected = '123.456.23.123';
744-
$_SERVER['REMOTE_ADDR'] = '10.10.1.200';
750+
$expected = '10.10.1.200';
751+
$_SERVER['REMOTE_ADDR'] = $expected;
752+
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.456.23.123';
745753
$config = new App();
746754
$config->proxyIPs = '10.0.1.200,192.168.5.0/24';
747-
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
748-
$this->request = new Request($config);
755+
756+
$this->request = new Request($config);
757+
$this->request->populateHeaders();
749758

750759
// spoofed address invalid
751-
$this->assertSame('10.10.1.200', $this->request->getIPAddress());
760+
$this->assertSame($expected, $this->request->getIPAddress());
752761
}
753762

754763
public function testGetIPAddressThruProxySubnet()
755764
{
756765
$expected = '123.123.123.123';
766+
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
757767
$_SERVER['REMOTE_ADDR'] = '192.168.5.21';
758768
$config = new App();
759769
$config->proxyIPs = ['192.168.5.0/24'];
760-
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
761-
$this->request = new Request($config);
770+
771+
$this->request = new Request($config);
772+
$this->request->populateHeaders();
762773

763774
// we should see the original forwarded address
764775
$this->assertSame($expected, $this->request->getIPAddress());
765776
}
766777

767778
public function testGetIPAddressThruProxyOutofSubnet()
768779
{
769-
$expected = '123.123.123.123';
770-
$_SERVER['REMOTE_ADDR'] = '192.168.5.21';
780+
$expected = '192.168.5.21';
781+
$_SERVER['REMOTE_ADDR'] = $expected;
771782
$config = new App();
772783
$config->proxyIPs = ['192.168.5.0/28'];
773-
$_SERVER['HTTP_X_FORWARDED_FOR'] = $expected;
784+
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.123.123.123';
774785
$this->request = new Request($config);
786+
$this->request->populateHeaders();
775787

776788
// we should see the original forwarded address
777-
$this->assertSame('192.168.5.21', $this->request->getIPAddress());
789+
$this->assertSame($expected, $this->request->getIPAddress());
778790
}
779791

780792
// @TODO getIPAddress should have more testing, to 100% code coverage

tests/system/HTTP/MessageTest.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ protected function setUp(): void
3030
$this->message = new Message();
3131
}
3232

33-
protected function tearDown(): void
34-
{
35-
$this->message = null;
36-
unset($this->message);
37-
}
38-
3933
// We can only test the headers retrieved from $_SERVER
4034
// This test might fail under apache.
4135
public function testHeadersRetrievesHeaders()
@@ -246,23 +240,24 @@ public function testSetHeaderWithExistingArrayValuesAppendNullValue()
246240

247241
public function testPopulateHeadersWithoutContentType()
248242
{
249-
// fail path, if the CONTENT_TYPE doesn't exist
250243
$original = $_SERVER;
251-
$_SERVER = ['HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.50'];
252244
$originalEnv = getenv('CONTENT_TYPE');
245+
246+
// fail path, if the CONTENT_TYPE doesn't exist
247+
$_SERVER = ['HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.50'];
253248
putenv('CONTENT_TYPE');
254249

255250
$this->message->populateHeaders();
256251

257252
$this->assertNull($this->message->header('content-type'));
253+
258254
putenv("CONTENT_TYPE={$originalEnv}");
259-
$this->message->removeHeader('accept-language');
260255
$_SERVER = $original; // restore so code coverage doesn't break
261256
}
262257

263258
public function testPopulateHeadersWithoutHTTP()
264259
{
265-
// fail path, if arguement does't have the HTTP_*
260+
// fail path, if argument doesn't have the HTTP_*
266261
$original = $_SERVER;
267262
$_SERVER = [
268263
'USER_AGENT' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405',
@@ -273,6 +268,7 @@ public function testPopulateHeadersWithoutHTTP()
273268

274269
$this->assertNull($this->message->header('user-agent'));
275270
$this->assertNull($this->message->header('request-method'));
271+
276272
$_SERVER = $original; // restore so code coverage doesn't break
277273
}
278274

@@ -288,7 +284,7 @@ public function testPopulateHeadersKeyNotExists()
288284
$this->message->populateHeaders();
289285

290286
$this->assertSame('', $this->message->header('accept-charset')->getValue());
291-
$this->message->removeHeader('accept-charset');
287+
292288
$_SERVER = $original; // restore so code coverage doesn't break
293289
}
294290

@@ -305,8 +301,7 @@ public function testPopulateHeaders()
305301

306302
$this->assertSame('text/html; charset=utf-8', $this->message->header('content-type')->getValue());
307303
$this->assertSame('en-us,en;q=0.50', $this->message->header('accept-language')->getValue());
308-
$this->message->removeHeader('content-type');
309-
$this->message->removeHeader('accept-language');
304+
310305
$_SERVER = $original; // restore so code coverage doesn't break
311306
}
312307
}

0 commit comments

Comments
 (0)