Skip to content

Commit 1845f8c

Browse files
authored
Merge branch 'develop' into subnamespace
2 parents b618dcf + 3dafe0b commit 1845f8c

10 files changed

Lines changed: 75 additions & 45 deletions

File tree

‎composer.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"boundwize/structarmed": "0.6.15",
20+
"boundwize/structarmed": "0.9.1",
2121
"codeigniter/phpstan-codeigniter": "^1.5",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/tachycardia": "^2.0",
2626
"phpstan/extension-installer": "^1.4",
27-
"phpstan/phpstan": "^2.1.55",
27+
"phpstan/phpstan": "^2.2.1",
2828
"phpstan/phpstan-strict-rules": "^2.0",
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.4.4",
32+
"rector/rector": "2.4.5",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

‎system/Database/BaseBuilder.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,13 @@ protected function validateUpdate(): bool
25892589
*/
25902590
public function updateBatch($set = null, $constraints = null, int $batchSize = 100)
25912591
{
2592+
if ($this->QBWhere !== []) {
2593+
throw new DatabaseException(
2594+
'updateBatch() cannot be safely combined with existing Query Builder WHERE conditions. '
2595+
. 'Use updateBatch($data, $constraints), onConstraint(), or include all required constraint fields in the batch data.',
2596+
);
2597+
}
2598+
25922599
$this->onConstraint($constraints);
25932600

25942601
if (isset($this->QBOptions['setQueryAsData'])) {

‎system/HTTP/UserAgent.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,15 @@ protected function setBrowser(): bool
317317
if (is_array($this->config->browsers) && $this->config->browsers !== []) {
318318
foreach ($this->config->browsers as $key => $val) {
319319
if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->agent, $match)) {
320+
$version = $match[1];
321+
322+
// Safari's browser version is reported in the Version token.
323+
if ($val === 'Safari' && preg_match('|Version/([0-9\.]+).*?Safari|i', $this->agent, $safariMatch)) {
324+
$version = $safariMatch[1];
325+
}
326+
320327
$this->isBrowser = true;
321-
$this->version = $match[1];
328+
$this->version = $version;
322329
$this->browser = $val;
323330
$this->setMobile();
324331

‎tests/system/Database/Builder/UpdateTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ public function testUpdateBatchThrowsExceptionWithNoData(): void
299299
$builder->updateBatch(null, 'id');
300300
}
301301

302+
public function testUpdateBatchThrowsExceptionWithWhere(): void
303+
{
304+
$builder = new BaseBuilder('jobs', $this->db);
305+
306+
$this->expectException(DatabaseException::class);
307+
$this->expectExceptionMessage(
308+
'updateBatch() cannot be safely combined with existing Query Builder WHERE conditions. '
309+
. 'Use updateBatch($data, $constraints), onConstraint(), or include all required constraint fields in the batch data.',
310+
);
311+
312+
$builder->where('description', 'old')->updateBatch([
313+
[
314+
'id' => 2,
315+
'name' => 'Comedian',
316+
],
317+
], 'id');
318+
}
319+
302320
public function testUpdateBatchThrowsExceptionWithNoID(): void
303321
{
304322
$builder = new BaseBuilder('jobs', $this->db);

‎tests/system/HTTP/UserAgentTest.php‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,38 @@ public function testBrowserInfo(): void
7474
{
7575
$this->assertSame('Mac OS X', $this->agent->getPlatform());
7676
$this->assertSame('Safari', $this->agent->getBrowser());
77-
$this->assertSame('533.20.27', $this->agent->getVersion());
77+
$this->assertSame('5.0.4', $this->agent->getVersion());
7878
$this->assertSame('', $this->agent->getRobot());
7979
}
8080

81+
public function testParseModernSafariUsesVersionToken(): void
82+
{
83+
$this->agent->parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 13_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15');
84+
85+
$this->assertSame('Mac OS X', $this->agent->getPlatform());
86+
$this->assertSame('Safari', $this->agent->getBrowser());
87+
$this->assertSame('16.3', $this->agent->getVersion());
88+
}
89+
90+
public function testParseMobileSafariUsesVersionToken(): void
91+
{
92+
$this->agent->parse($this->_mobile_ua);
93+
94+
$this->assertSame('iOS', $this->agent->getPlatform());
95+
$this->assertSame('Safari', $this->agent->getBrowser());
96+
$this->assertSame('4.0.5', $this->agent->getVersion());
97+
$this->assertSame('Apple iPhone', $this->agent->getMobile());
98+
}
99+
100+
public function testParseChromeWithSafariTokenUsesChromeVersion(): void
101+
{
102+
$this->agent->parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36');
103+
104+
$this->assertSame('Mac OS X', $this->agent->getPlatform());
105+
$this->assertSame('Chrome', $this->agent->getBrowser());
106+
$this->assertSame('110.0.0.0', $this->agent->getVersion());
107+
}
108+
81109
public function testParse(): void
82110
{
83111
$newAgent = 'Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0';

‎user_guide_src/source/changelogs/v4.7.4.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Deprecations
3030
Bugs Fixed
3131
**********
3232

33+
- **Database:** Fixed a bug where ``updateBatch()`` could be called after Query Builder ``where()`` conditions, even though it's not supported. In this situation, now the ``DatabaseException`` is thrown.
34+
- **HTTP:** Fixed a bug where the User Agent library reported Safari's WebKit version instead of the browser version from the ``Version`` token.
35+
3336
See the repo's
3437
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
3538
for a complete list of bugs fixed.

‎user_guide_src/source/libraries/official_packages.rst‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ while defaulting to the config files when not custom value has been stored. This
4141
an application to ship with the default config values, but adapt as the project grows
4242
or moves servers, without having to touch the code.
4343

44-
************
45-
Tasks (BETA)
46-
************
44+
*****
45+
Tasks
46+
*****
4747

4848
`CodeIgniter Tasks <https://tasks.codeigniter.com>`_ is a simple task scheduler
4949
for CodeIgniter 4. It allows you to schedule tasks to run at specific times, or
5050
on a recurring basis. It is designed to be simple to use, but flexible enough to
5151
handle most use cases.
5252

53-
************
54-
Queue (BETA)
55-
************
53+
*****
54+
Queue
55+
*****
5656

5757
`CodeIgniter Queue <https://queue.codeigniter.com>`_ is a simple queue system
5858
for CodeIgniter 4. It allows you to queue up tasks to be run later.

‎utils/phpstan-baseline/function.alreadyNarrowedType.neon‎

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

‎utils/phpstan-baseline/function.impossibleType.neon‎

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

‎utils/phpstan-baseline/loader.neon‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 2015 errors
1+
# total 2010 errors
22

33
includes:
44
- argument.type.neon
@@ -10,8 +10,6 @@ includes:
1010
- codeigniter.superglobalAccessAssign.neon
1111
- deadCode.unreachable.neon
1212
- empty.notAllowed.neon
13-
- function.alreadyNarrowedType.neon
14-
- function.impossibleType.neon
1513
- method.alreadyNarrowedType.neon
1614
- method.childParameterType.neon
1715
- method.childReturnType.neon

0 commit comments

Comments
 (0)