Skip to content

Commit c970fd7

Browse files
committed
Merge branch 'develop' into 4.7
2 parents b1f2bee + 38c1c79 commit c970fd7

File tree

28 files changed

+183
-129
lines changed

28 files changed

+183
-129
lines changed

admin/css/debug-toolbar/toolbar.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,31 @@
457457
}
458458
}
459459

460+
@media screen and (max-width: 768px) {
461+
#debug-bar {
462+
table {
463+
display: block;
464+
overflow-x: auto;
465+
font-size: 12px;
466+
margin: 5px 5px 10px 5px;
467+
468+
td,
469+
th {
470+
padding: 4px 6px;
471+
}
472+
}
473+
474+
.timeline {
475+
display: block;
476+
white-space: nowrap;
477+
font-size: 12px;
478+
}
479+
480+
.toolbar {
481+
overflow-x: auto;
482+
}
483+
}
484+
}
460485

461486
// THEMES
462487
// ========================================================================== */

app/Views/errors/html/debug.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--main-text-color: #555;
44
--dark-text-color: #222;
55
--light-text-color: #c7c7c7;
6-
--brand-primary-color: #E06E3F;
6+
--brand-primary-color: #DC4814;
77
--light-bg-color: #ededee;
88
--dark-bg-color: #404040;
99
}
@@ -71,7 +71,7 @@ p.lead {
7171
text-align: center;
7272
padding: calc(4px + 0.2083vw);
7373
width: 100%;
74-
margin-top: -2.14rem;
74+
top: 0;
7575
position: fixed;
7676
}
7777

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^1.1 || ^2.3",
31-
"rector/rector": "2.0.9",
31+
"rector/rector": "2.0.10",
3232
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3333
},
3434
"replace": {

system/Cache/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function deleteMatching(string $pattern)
181181
$iterator = null;
182182

183183
do {
184-
/** @var false|list<string>|Redis $keys */
184+
/** @var false|list<string> $keys */
185185
$keys = $this->redis->scan($iterator, $pattern);
186186

187187
if (is_array($keys)) {

system/Commands/Generators/MigrationGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ protected function prepare(string $class): string
112112
$data['DBGroup'] = is_string($DBGroup) ? $DBGroup : 'default';
113113
$data['DBDriver'] = config(Database::class)->{$data['DBGroup']}['DBDriver'];
114114

115-
/** @var SessionConfig|null $session */
116-
$session = config(SessionConfig::class);
117-
118-
$data['matchIP'] = $session->matchIP;
115+
$data['matchIP'] = config(SessionConfig::class)->matchIP;
119116
}
120117

121118
return $this->parseTemplate($class, [], [], $data);

system/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ function db_connect($db = null, bool $getShared = true)
371371
* retrieving values set from the .env file for
372372
* use in config files.
373373
*
374-
* @param string|null $default
374+
* @param array<int|string, mixed>|bool|float|int|object|string|null $default
375375
*
376-
* @return bool|string|null
376+
* @return array<int|string, mixed>|bool|float|int|object|string|null
377377
*/
378378
function env(string $key, $default = null)
379379
{

system/Database/Postgre/Builder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
469469
return ($index->type === 'UNIQUE' || $index->type === 'PRIMARY') && $hasAllFields;
470470
});
471471

472-
foreach (array_map(static fn ($index) => $index->fields, $allIndexes) as $index) {
473-
$constraints[] = current($index);
474-
// only one index can be used?
472+
foreach ($allIndexes as $index) {
473+
$constraints = $index->fields;
475474
break;
476475
}
477476

system/Database/SQLite3/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
151151
return ($index->type === 'PRIMARY' || $index->type === 'UNIQUE') && $hasAllFields;
152152
});
153153

154-
foreach (array_map(static fn ($index) => $index->fields, $allIndexes) as $index) {
155-
$constraints[] = current($index);
154+
foreach ($allIndexes as $index) {
155+
$constraints = $index->fields;
156156
break;
157157
}
158158

system/Debug/Toolbar/Views/toolbar.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@
332332
display: none !important;
333333
}
334334
}
335+
@media screen and (max-width: 768px) {
336+
#debug-bar table {
337+
display: block;
338+
overflow-x: auto;
339+
font-size: 12px;
340+
margin: 5px 5px 10px 5px;
341+
}
342+
#debug-bar table td,
343+
#debug-bar table th {
344+
padding: 4px 6px;
345+
}
346+
#debug-bar .timeline {
347+
display: block;
348+
white-space: nowrap;
349+
font-size: 12px;
350+
}
351+
#debug-bar .toolbar {
352+
overflow-x: auto;
353+
}
354+
}
335355
#debug-icon {
336356
background-color: #FFFFFF;
337357
box-shadow: 0 0 4px #DFDFDF;

system/HTTP/CURLRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
125125
$this->baseURI = $uri->useRawQueryString();
126126
$this->defaultOptions = $options;
127127

128-
/** @var ConfigCURLRequest|null $configCURLRequest */
129-
$configCURLRequest = config(ConfigCURLRequest::class);
130-
$this->shareOptions = $configCURLRequest->shareOptions ?? true;
128+
$this->shareOptions = config(ConfigCURLRequest::class)->shareOptions ?? true;
131129

132130
$this->config = $this->defaultConfig;
133131
$this->parseOptions($options);

system/I18n/TimeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
trait TimeTrait
3333
{
3434
/**
35-
* @var DateTimeZone
35+
* @var DateTimeZone|string
3636
*/
3737
protected $timezone;
3838

system/Test/ReflectionHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ trait ReflectionHelper
3131
* @param object|string $obj object or class name
3232
* @param string $method method name
3333
*
34-
* @return Closure
35-
* @phpstan-return Closure(mixed ...$args): mixed
34+
* @return Closure(mixed ...$args): mixed
3635
*
3736
* @throws ReflectionException
3837
*/

tests/_support/Database/Migrations/20160428212500_Create_test_tables.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public function up(): void
4747
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
4848
])->addKey('id', true)->createTable('misc', true);
4949

50+
// Team members Table (composite key)
51+
$this->forge->addField([
52+
'team_id' => ['type' => 'INTEGER', 'constraint' => 3],
53+
'person_id' => ['type' => 'INTEGER', 'constraint' => 3],
54+
'role' => ['type' => 'VARCHAR', 'constraint' => 40],
55+
'status' => ['type' => 'VARCHAR', 'constraint' => 40],
56+
'created_at' => ['type' => 'DATETIME', 'null' => true],
57+
])->addUniqueKey(['team_id', 'person_id'])->createTable('team_members', true);
58+
5059
// Database Type test table
5160
// missing types:
5261
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY,TINYTEXT,LONGTEXT,

tests/_support/Database/Seeds/CITestSeeder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ public function run(): void
107107
'value' => 'ടൈപ്പ്',
108108
],
109109
],
110+
'team_members' => [
111+
[
112+
'team_id' => 1,
113+
'person_id' => 22,
114+
'role' => 'member',
115+
'status' => 'active',
116+
],
117+
[
118+
'team_id' => 1,
119+
'person_id' => 33,
120+
'role' => 'mentor',
121+
'status' => 'active',
122+
],
123+
],
110124
'type_test' => [
111125
[
112126
'type_varchar' => 'test',

tests/system/Commands/Utilities/ConfigCheckTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public function testCommandConfigCheckNonexistentClass(): void
8989

9090
public function testConfigCheckWithKintEnabledUsesKintD(): void
9191
{
92-
/** @var Closure(object): string $command */
92+
/**
93+
* @var Closure(mixed...): string
94+
*/
9395
$command = $this->getPrivateMethodInvoker(
9496
new ConfigCheck(service('logger'), service('commands')),
9597
'getKintD',
@@ -105,7 +107,9 @@ public function testConfigCheckWithKintEnabledUsesKintD(): void
105107

106108
public function testConfigCheckWithKintDisabledUsesVarDump(): void
107109
{
108-
/** @var Closure(object): string $command */
110+
/**
111+
* @var Closure(mixed...): string
112+
*/
109113
$command = $this->getPrivateMethodInvoker(
110114
new ConfigCheck(service('logger'), service('commands')),
111115
'getVarDump',

tests/system/Database/Live/MetadataTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected function setUp(): void
4747
$prefix . 'user',
4848
$prefix . 'job',
4949
$prefix . 'misc',
50+
$prefix . 'team_members',
5051
$prefix . 'type_test',
5152
$prefix . 'empty',
5253
$prefix . 'secondary',

tests/system/Database/Live/UpsertTest.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function testUpsertBatchWithOnConflictAndUpdateFields(): void
448448
$this->assertSame('El Salvador', $data[4]->country);
449449
}
450450

451-
public function testUpsertWithMatchingDataOnUniqueIndexandPrimaryKey(): void
451+
public function testUpsertWithMatchingDataOnUniqueIndexAndPrimaryKey(): void
452452
{
453453
$data = [
454454
'id' => 6,
@@ -607,6 +607,36 @@ public function testUpsertBatchMultipleConstraints(): void
607607
}
608608
}
609609

610+
/**
611+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/9450
612+
*/
613+
public function testUpsertBatchCompositeUniqueIndex(): void
614+
{
615+
$data = [
616+
[
617+
'team_id' => 1,
618+
'person_id' => 22,
619+
'role' => 'leader',
620+
'status' => 'active',
621+
],
622+
[
623+
'team_id' => 1,
624+
'person_id' => 33,
625+
'role' => 'member',
626+
'status' => 'active',
627+
],
628+
];
629+
630+
// uses (team_id, person_id) - composite unique index
631+
$this->db->table('team_members')->upsertBatch($data);
632+
633+
$this->seeInDatabase('team_members', ['team_id' => 1, 'person_id' => 22, 'role' => 'leader']);
634+
$this->dontSeeInDatabase('team_members', ['team_id' => 1, 'person_id' => 22, 'role' => 'member']);
635+
636+
$this->seeInDatabase('team_members', ['team_id' => 1, 'person_id' => 33, 'role' => 'member']);
637+
$this->dontSeeInDatabase('team_members', ['team_id' => 1, 'person_id' => 33, 'role' => 'mentor']);
638+
}
639+
610640
public function testSetBatchOneRow(): void
611641
{
612642
$data = [

tests/system/Filters/DebugToolbarTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use CodeIgniter\HTTP\IncomingRequest;
1818
use CodeIgniter\HTTP\RequestInterface;
1919
use CodeIgniter\HTTP\Response;
20+
use CodeIgniter\HTTP\ResponseInterface;
2021
use CodeIgniter\Test\CIUnitTestCase;
2122
use Config\Filters as FilterConfig;
2223
use PHPUnit\Framework\Attributes\BackupGlobals;
@@ -60,11 +61,13 @@ public function testDebugToolbarFilter(): void
6061
$expectedAfter = $this->response;
6162

6263
// nothing should change here, since we have no before logic
63-
$filter->before($this->request);
64+
$result = $filter->before($this->request);
6465
$this->assertSame($expectedBefore, $this->request);
66+
$this->assertNull($result);
6567

6668
// nothing should change here, since we are running in the CLI
67-
$filter->after($this->request, $this->response);
69+
$result = $filter->after($this->request, $this->response);
6870
$this->assertSame($expectedAfter, $this->response);
71+
$this->assertNotInstanceOf(ResponseInterface::class, $result);
6972
}
7073
}

tests/system/I18n/TimeLegacyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,11 @@ public function testHumanizeWithArLocale(): void
10911091
$this->resetServices();
10921092

10931093
$currentLocale = Locale::getDefault();
1094-
Locale::setDefault('ar');
1094+
Locale::setDefault('ar-SA');
10951095

10961096
$config = new App();
1097-
$config->supportedLocales = ['ar'];
1098-
$config->defaultLocale = 'ar';
1097+
$config->supportedLocales = ['ar-SA'];
1098+
$config->defaultLocale = 'ar-SA';
10991099
Factories::injectMock('config', 'App', $config);
11001100

11011101
TimeLegacy::setTestNow('2022-06-14 12:00', 'America/Chicago');

tests/system/I18n/TimeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,11 +1176,11 @@ public function testHumanizeWithArLocale(): void
11761176
$this->resetServices();
11771177

11781178
$currentLocale = Locale::getDefault();
1179-
Locale::setDefault('ar');
1179+
Locale::setDefault('ar-SA');
11801180

11811181
$config = new App();
1182-
$config->supportedLocales = ['ar'];
1183-
$config->defaultLocale = 'ar';
1182+
$config->supportedLocales = ['ar-SA'];
1183+
$config->defaultLocale = 'ar-SA';
11841184
Factories::injectMock('config', 'App', $config);
11851185

11861186
Time::setTestNow('2022-06-14 12:00', 'America/Chicago');

0 commit comments

Comments
 (0)