Skip to content

Commit c9999cf

Browse files
authored
Merge branch '4.3' into BatchUpdateSQL
2 parents b69980b + f9da5ad commit c9999cf

27 files changed

+254
-130
lines changed

admin/RELEASE.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ git clone [email protected]:codeigniter4/userguide.git
5151
* Create a new PR from `develop` to `master`:
5252
* Title: "4.x.x Ready code"
5353
* Description: blank
54-
* Merge the PR then fast-forward `develop` to catch the merge commit
55-
* Update the next minor upgrade branch `4.x`
56-
```console
57-
git fetch origin
58-
git checkout 4.x
59-
git merge origin/4.x
60-
git merge origin/develop
61-
git push origin HEAD
62-
```
63-
* Create a new Release:
54+
* Merge the PR then create a new Release:
6455
* Version: "v4.x.x"
6556
* Title: "CodeIgniter 4.x.x"
6657
* Description:
@@ -76,25 +67,23 @@ composer create-project codeigniter4/appstarter release-test
7667
cd release-test
7768
composer test && composer info codeigniter4/framework
7869
```
79-
* publish any Security Advisories that were resolved from private forks
80-
81-
## User Guide
82-
83-
**This is now handled by GitHub Actions!**
84-
85-
Verify that the Actions succeeded:
86-
* "Deploy User Guide", this repo
87-
* "Deploy Production", UG repo
88-
* "pages-build-deployment", both repos
89-
90-
See the legacy notes in Appendix for reference or to help manually recover from workflow failures.
91-
92-
## Announcement
93-
94-
> Note: This forum is restricted to administrators.
95-
96-
* Make a new topic in the "News & Discussion" forums: https://forum.codeigniter.com/forum-2.html
97-
* The content is somewhat organic, but should include any major features and changes as well as a link to the User Guide's changelog
70+
* Verify that the User Guide Actions succeeded:
71+
* "Deploy User Guide", framework repo
72+
* "Deploy Production", UG repo
73+
* "pages-build-deployment", both repos
74+
* Fast-forward `develop` branch to catch the merge commit from `master`
75+
* Update the next minor upgrade branch `4.x`:
76+
```console
77+
git fetch origin
78+
git checkout 4.x
79+
git merge origin/4.x
80+
git merge origin/develop
81+
git push origin HEAD
82+
```
83+
* Publish any Security Advisories that were resolved from private forks
84+
* Announce the release on the forums and Slack channel (note: this forum is restricted to administrators):
85+
* Make a new topic in the "News & Discussion" forums: https://forum.codeigniter.com/forum-2.html
86+
* The content is somewhat organic, but should include any major features and changes as well as a link to the User Guide's changelog
9887

9988
## After Publishing Security Advisory
10089

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"phpstan/phpstan": "^1.7.1",
2525
"phpunit/phpunit": "^9.1",
2626
"predis/predis": "^1.1 || ^2.0",
27-
"rector/rector": "0.14.1",
27+
"rector/rector": "0.14.2",
2828
"vimeo/psalm": "^4.26"
2929
},
3030
"suggest": {

contributing/workflow.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,29 @@ For instance, to commit your work from a debugging session:
179179

180180
Just make sure that your commits in a feature branch are all related.
181181

182+
### GPG-Signing Old Commits
183+
184+
Any developer can forget GPG-signing their commits with the option `-S`, like `git commit -S -m 'Signed GPG'`. In such a case, all you need to do is the following:
185+
186+
Latest commit only:
187+
```console
188+
> git switch your-branch
189+
> git commit --amend --no-edit --no-verify -S
190+
> git push --force-with-lease origin your-branch
191+
```
192+
193+
All commits:
194+
```console
195+
> git switch your-branch
196+
> git rebase -i --root --exec 'git commit --amend --no-edit --no-verify -S'
197+
> git push --force-with-lease origin your-branch
198+
```
199+
200+
As a faster alternative, you can still securely sign commits without the `-S` option in `git commit` by setting `git config --global commit.gpgsign true` and `git config --global user.signingkey 3AC5C34371567BD2` to all local repositories. Without the `--global` option, the change is applied to one local repository only.
201+
202+
> **Note**
203+
> `3AC5C34371567BD2` is your GPG Key ID
204+
182205
### Changing a Commit Message
183206

184207
See <https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message>.

phpstan-baseline.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,6 @@ parameters:
635635
count: 1
636636
path: system/Throttle/Throttler.php
637637

638-
-
639-
message: "#^Variable \\$error on left side of \\?\\? always exists and is always null\\.$#"
640-
count: 1
641-
path: system/Validation/Validation.php
642-
643638
-
644639
message: "#^Property CodeIgniter\\\\View\\\\Cell\\:\\:\\$cache \\(CodeIgniter\\\\Cache\\\\CacheInterface\\) in empty\\(\\) is not falsy\\.$#"
645640
count: 2

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@
110110
__DIR__ . '/app/Config/Validation.php',
111111
__DIR__ . '/tests/system/Validation/StrictRules/ValidationTest.php',
112112
__DIR__ . '/tests/system/Validation/ValidationTest.php',
113-
114-
// expected Qualified name
115-
__DIR__ . '/tests/system/Autoloader/FileLocatorTest.php',
116-
__DIR__ . '/tests/system/Router/RouteCollectionTest.php',
117113
],
118114

119115
// sometime too detail

system/BaseModel.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use CodeIgniter\Exceptions\ModelException;
2020
use CodeIgniter\I18n\Time;
2121
use CodeIgniter\Pager\Pager;
22-
use CodeIgniter\Validation\Validation;
2322
use CodeIgniter\Validation\ValidationInterface;
2423
use Config\Services;
2524
use InvalidArgumentException;
@@ -198,7 +197,7 @@ abstract class BaseModel
198197
/**
199198
* Our validator instance.
200199
*
201-
* @var Validation
200+
* @var ValidationInterface
202201
*/
203202
protected $validation;
204203

@@ -326,7 +325,7 @@ public function __construct(?ValidationInterface $validation = null)
326325
$this->tempAllowCallbacks = $this->allowCallbacks;
327326

328327
/**
329-
* @var Validation|null $validation
328+
* @var ValidationInterface|null $validation
330329
*/
331330
$validation ??= Services::validation(null, false);
332331
$this->validation = $validation;

system/CodeIgniter.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -718,18 +718,13 @@ protected function generateCacheName(Cache $config): string
718718
return md5($this->request->getPath());
719719
}
720720

721-
$uri = $this->request->getUri();
722-
if ($config->cacheQueryString) {
723-
if (is_array($config->cacheQueryString)) {
724-
$name = URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath(), $uri->getQuery(['only' => $config->cacheQueryString]));
725-
} else {
726-
$name = URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath(), $uri->getQuery());
727-
}
728-
} else {
729-
$name = URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath());
730-
}
721+
$uri = clone $this->request->getUri();
722+
723+
$query = $config->cacheQueryString
724+
? $uri->getQuery(is_array($config->cacheQueryString) ? ['only' => $config->cacheQueryString] : [])
725+
: '';
731726

732-
return md5($name);
727+
return md5($uri->setFragment('')->setQuery($query));
733728
}
734729

735730
/**

system/Config/BaseService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
use CodeIgniter\Session\Session;
5050
use CodeIgniter\Throttle\Throttler;
5151
use CodeIgniter\Typography\Typography;
52-
use CodeIgniter\Validation\Validation;
52+
use CodeIgniter\Validation\ValidationInterface;
5353
use CodeIgniter\View\Cell;
5454
use CodeIgniter\View\Parser;
5555
use CodeIgniter\View\RendererInterface;
@@ -127,7 +127,7 @@
127127
* @method static Toolbar toolbar(ConfigToolbar $config = null, $getShared = true)
128128
* @method static Typography typography($getShared = true)
129129
* @method static URI uri($uri = null, $getShared = true)
130-
* @method static Validation validation(ConfigValidation $config = null, $getShared = true)
130+
* @method static ValidationInterface validation(ConfigValidation $config = null, $getShared = true)
131131
* @method static Cell viewcell($getShared = true)
132132
*/
133133
class BaseService

system/Config/Services.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use CodeIgniter\Throttle\Throttler;
5555
use CodeIgniter\Typography\Typography;
5656
use CodeIgniter\Validation\Validation;
57+
use CodeIgniter\Validation\ValidationInterface;
5758
use CodeIgniter\View\Cell;
5859
use CodeIgniter\View\Parser;
5960
use CodeIgniter\View\RendererInterface;
@@ -733,7 +734,7 @@ public static function uri(?string $uri = null, bool $getShared = true)
733734
/**
734735
* The Validation class provides tools for validating input data.
735736
*
736-
* @return Validation
737+
* @return ValidationInterface
737738
*/
738739
public static function validation(?ValidationConfig $config = null, bool $getShared = true)
739740
{

system/Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use CodeIgniter\HTTP\RequestInterface;
1616
use CodeIgniter\HTTP\ResponseInterface;
1717
use CodeIgniter\Validation\Exceptions\ValidationException;
18-
use CodeIgniter\Validation\Validation;
18+
use CodeIgniter\Validation\ValidationInterface;
1919
use Config\Services;
2020
use Psr\Log\LoggerInterface;
2121

@@ -62,7 +62,7 @@ class Controller
6262
/**
6363
* Once validation has been run, will hold the Validation instance.
6464
*
65-
* @var Validation
65+
* @var ValidationInterface
6666
*/
6767
protected $validator;
6868

system/Database/BaseConnection.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @property mixed $encrypt
3333
* @property array $failover
3434
* @property string $hostname
35-
* @property mixed $lastQuery
35+
* @property Query $lastQuery
3636
* @property string $password
3737
* @property bool $pConnect
3838
* @property int|string $port
@@ -151,7 +151,7 @@ abstract class BaseConnection implements ConnectionInterface
151151
/**
152152
* Encryption flag/data
153153
*
154-
* @var mixed
154+
* @var array|bool
155155
*/
156156
protected $encrypt = false;
157157

@@ -182,7 +182,7 @@ abstract class BaseConnection implements ConnectionInterface
182182
* The last query object that was executed
183183
* on this connection.
184184
*
185-
* @var mixed
185+
* @var Query
186186
*/
187187
protected $lastQuery;
188188

@@ -933,7 +933,7 @@ public function prepare(Closure $func, array $options = [])
933933
/**
934934
* Returns the last query's statement object.
935935
*
936-
* @return mixed
936+
* @return Query
937937
*/
938938
public function getLastQuery()
939939
{
@@ -1150,9 +1150,10 @@ private function protectDotItem(string $item, string $alias, bool $protectIdenti
11501150
*
11511151
* This function escapes column and table names
11521152
*
1153-
* @param mixed $item
1153+
* @param array|string $item
11541154
*
1155-
* @return mixed
1155+
* @return array|string
1156+
* @phpstan-return ($item is array ? array : string)
11561157
*/
11571158
public function escapeIdentifiers($item)
11581159
{
@@ -1232,9 +1233,10 @@ abstract public function affectedRows(): int;
12321233
* Escapes data based on type.
12331234
* Sets boolean and null types
12341235
*
1235-
* @param mixed $str
1236+
* @param array|bool|float|int|object|string|null $str
12361237
*
1237-
* @return mixed
1238+
* @return array|float|int|string
1239+
* @phpstan-return ($str is array ? array : float|int|string)
12381240
*/
12391241
public function escape($str)
12401242
{

system/Database/ConnectionInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ public function getLastQuery();
131131
* Escapes data based on type.
132132
* Sets boolean and null types.
133133
*
134-
* @param mixed $str
134+
* @param array|bool|float|int|object|string|null $str
135135
*
136-
* @return mixed
136+
* @return array|float|int|string
137+
* @phpstan-return ($str is array ? array : float|int|string)
137138
*/
138139
public function escape($str);
139140

system/Database/Postgre/Connection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ public function affectedRows(): int
171171
*
172172
* Escapes data based on type
173173
*
174-
* @param mixed $str
174+
* @param array|bool|float|int|object|string|null $str
175175
*
176-
* @return mixed
176+
* @return array|float|int|string
177+
* @phpstan-return ($str is array ? array : float|int|string)
177178
*/
178179
public function escape($str)
179180
{

system/I18n/Time.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,11 @@ protected static function hasRelativeKeywords(string $time): bool
11221122

11231123
/**
11241124
* Outputs a short format version of the datetime.
1125-
*
1126-
* @throws Exception
1125+
* The output is NOT localized intentionally.
11271126
*/
11281127
public function __toString(): string
11291128
{
1130-
return IntlDateFormatter::formatObject($this->toDateTime(), $this->toStringFormat, $this->locale);
1129+
return $this->format('Y-m-d H:i:s');
11311130
}
11321131

11331132
/**
@@ -1180,12 +1179,4 @@ public function __wakeup(): void
11801179
$this->timezone = new DateTimeZone($timezone);
11811180
parent::__construct($this->date, $this->timezone);
11821181
}
1183-
1184-
/**
1185-
* Returns the datetime string ('Y-m-d H:i:s') that is safe to databases regardless of locale.
1186-
*/
1187-
public function toDatabase(): string
1188-
{
1189-
return $this->format('Y-m-d H:i:s');
1190-
}
11911182
}

system/Validation/Validation.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ protected function processRules(
331331

332332
$param = ($param === false) ? '' : $param;
333333

334+
// @phpstan-ignore-next-line $error may be set by rule methods.
334335
$this->errors[$field] = $error ?? $this->getErrorMessage(
335336
$rule,
336337
$field,
@@ -405,7 +406,7 @@ public function withRequest(RequestInterface $request): ValidationInterface
405406
*
406407
* [
407408
* 'rule' => 'message',
408-
* 'rule' => 'message'
409+
* 'rule' => 'message',
409410
* ]
410411
*
411412
* @param array|string $rules
@@ -499,7 +500,7 @@ public function hasRule(string $field): bool
499500
*
500501
* @param string $group Group.
501502
*
502-
* @throws InvalidArgumentException If group not found.
503+
* @throws ValidationException If group not found.
503504
*
504505
* @return string[] Rule group.
505506
*/
@@ -521,7 +522,7 @@ public function getRuleGroup(string $group): array
521522
*
522523
* @param string $group Group.
523524
*
524-
* @throws InvalidArgumentException If group not found.
525+
* @throws ValidationException If group not found.
525526
*/
526527
public function setRuleGroup(string $group)
527528
{
@@ -593,12 +594,14 @@ protected function loadRuleSets()
593594
* same format used with setRules(). Additionally, check
594595
* for {group}_errors for an array of custom error messages.
595596
*
596-
* @return array|ValidationException|null
597+
* @throws ValidationException
598+
*
599+
* @return array
597600
*/
598601
public function loadRuleGroup(?string $group = null)
599602
{
600603
if (empty($group)) {
601-
return null;
604+
return [];
602605
}
603606

604607
if (! isset($this->config->{$group})) {

0 commit comments

Comments
 (0)