Skip to content

Commit 8fbdbd4

Browse files
committed
Merge branch 'develop' into 4.7
2 parents 86cf38a + 73718f4 commit 8fbdbd4

File tree

22 files changed

+112
-71
lines changed

22 files changed

+112
-71
lines changed

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.10",
31+
"rector/rector": "2.0.11",
3232
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3333
},
3434
"replace": {

rector.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
1919
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
2020
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
21-
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
2221
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
2322
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2423
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
@@ -36,8 +35,8 @@
3635
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
3736
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
3837
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
38+
use Rector\PHPUnit\CodeQuality\Rector\Class_\RemoveDataProviderParamKeysRector;
3939
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
40-
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertCountWithZeroToAssertEmptyRector;
4140
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
4241
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
4342
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
@@ -46,7 +45,6 @@
4645
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
4746
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
4847
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
49-
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
5048
use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
5149
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
5250
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
@@ -170,7 +168,7 @@
170168

171169
CompactToVariablesRector::class,
172170

173-
AssertCountWithZeroToAssertEmptyRector::class,
171+
RemoveDataProviderParamKeysRector::class,
174172
])
175173
// auto import fully qualified class names
176174
->withImportNames(removeUnusedImports: true)
@@ -192,7 +190,6 @@
192190
MakeInheritedMethodVisibilitySameAsParentRector::class,
193191
SimplifyEmptyCheckOnEmptyArrayRector::class,
194192
TernaryEmptyArrayArrayDimFetchToCoalesceRector::class,
195-
EmptyOnNullableObjectToInstanceOfRector::class,
196193
DisallowedEmptyRuleFixerRector::class,
197194
PrivatizeFinalClassPropertyRector::class,
198195
BooleanInIfConditionRuleFixerRector::class,
@@ -202,7 +199,6 @@
202199
AddMethodCallBasedStrictParamTypeRector::class,
203200
TypedPropertyFromAssignsRector::class,
204201
ClosureReturnTypeRector::class,
205-
FlipTypeControlToUseExclusiveTypeRector::class,
206202
AddArrowFunctionReturnTypeRector::class,
207203
])
208204
->withConfiguredRule(StringClassNameToClassConstantRector::class, [

system/BaseModel.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ abstract class BaseModel
121121
protected ?DataConverter $converter = null;
122122

123123
/**
124-
* If this model should use "softDeletes" and
125-
* simply set a date when rows are deleted, or
126-
* do hard deletes.
124+
* Determines whether the model should protect field names during
125+
* mass assignment operations such as insert() and update().
126+
*
127+
* When set to true, only the fields explicitly defined in the $allowedFields
128+
* property will be allowed for mass assignment. This helps prevent
129+
* unintended modification of database fields and improves security
130+
* by avoiding mass assignment vulnerabilities.
127131
*
128132
* @var bool
129133
*/

system/Database/OCI8/Builder.php

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ class Builder extends BaseBuilder
4848
*/
4949
protected $countString = 'SELECT COUNT(1) ';
5050

51-
/**
52-
* Limit used flag
53-
*
54-
* If we use LIMIT, we'll add a field that will
55-
* throw off num_fields later.
56-
*
57-
* @var bool
58-
*/
59-
protected $limitUsed = false;
60-
6151
/**
6252
* A reference to the database connection.
6353
*
@@ -214,28 +204,13 @@ protected function _update(string $table, array $values): string
214204
protected function _limit(string $sql, bool $offsetIgnore = false): string
215205
{
216206
$offset = (int) ($offsetIgnore === false ? $this->QBOffset : 0);
217-
if (version_compare($this->db->getVersion(), '12.1', '>=')) {
218-
// OFFSET-FETCH can be used only with the ORDER BY clause
219-
if (empty($this->QBOrderBy)) {
220-
$sql .= ' ORDER BY 1';
221-
}
222207

223-
return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY';
208+
// OFFSET-FETCH can be used only with the ORDER BY clause
209+
if (empty($this->QBOrderBy)) {
210+
$sql .= ' ORDER BY 1';
224211
}
225212

226-
$this->limitUsed = true;
227-
$limitTemplateQuery = 'SELECT * FROM (SELECT INNER_QUERY.*, ROWNUM RNUM FROM (%s) INNER_QUERY WHERE ROWNUM < %d)' . ($offset !== 0 ? ' WHERE RNUM >= %d' : '');
228-
229-
return sprintf($limitTemplateQuery, $sql, $offset + $this->QBLimit + 1, $offset);
230-
}
231-
232-
/**
233-
* Resets the query builder values. Called by the get() function
234-
*/
235-
protected function resetSelect()
236-
{
237-
$this->limitUsed = false;
238-
parent::resetSelect();
213+
return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY';
239214
}
240215

241216
/**

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ protected function format(string $data, string $format = 'html'): string
512512
{
513513
$data = json_decode($data, true);
514514

515-
if ($this->config->maxHistory !== 0 && preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
515+
if (preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
516516
$history = new History();
517517
$history->setFiles(
518518
$debugbarTime[0],

system/Debug/Toolbar/Views/toolbar.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,25 @@ var ciDebugBar = {
2727
.getElementById("debug-icon-link")
2828
.addEventListener("click", ciDebugBar.toggleToolbar, true);
2929

30-
// Allows to highlight the row of the current history request
31-
var btn = this.toolbar.querySelector(
32-
'button[data-time="' + localStorage.getItem("debugbar-time") + '"]'
33-
);
34-
ciDebugBar.addClass(btn.parentNode.parentNode, "current");
35-
3630
historyLoad = this.toolbar.getElementsByClassName("ci-history-load");
3731

38-
for (var i = 0; i < historyLoad.length; i++) {
39-
historyLoad[i].addEventListener(
40-
"click",
41-
function () {
42-
loadDoc(this.getAttribute("data-time"));
43-
},
44-
true
32+
if (historyLoad.length) {
33+
// Allows highlighting the row of the current history request
34+
var btn = this.toolbar.querySelector(
35+
'button[data-time="' + localStorage.getItem("debugbar-time-new") + '"]'
4536
);
37+
ciDebugBar.addClass(btn.parentNode.parentNode, "current");
38+
39+
40+
for (var i = 0; i < historyLoad.length; i++) {
41+
historyLoad[i].addEventListener(
42+
"click",
43+
function () {
44+
loadDoc(this.getAttribute("data-time"));
45+
},
46+
true
47+
);
48+
}
4649
}
4750

4851
// Display the active Tab on page load
@@ -77,14 +80,14 @@ var ciDebugBar = {
7780
links[i].addEventListener("click", function() {
7881
ciDebugBar.toggleDataTable(datatable)
7982
}, true);
80-
83+
8184
} else if (toggleData === "childrows") {
8285

8386
let child = links[i].getAttribute("data-child");
8487
links[i].addEventListener("click", function() {
8588
ciDebugBar.toggleChildRows(child)
8689
}, true);
87-
90+
8891
} else {
8992
links[i].addEventListener("click", ciDebugBar.toggleRows, true);
9093
}
@@ -174,10 +177,10 @@ var ciDebugBar = {
174177
);
175178

176179
if (target.classList.contains("debug-bar-ndisplay")) {
177-
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
180+
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
178181
} else {
179182
ciDebugBar.switchClass(target, "debug-bar-dtableRow", "debug-bar-ndisplay");
180-
}
183+
}
181184
}
182185
},
183186

@@ -261,7 +264,7 @@ var ciDebugBar = {
261264
} else {
262265
ciDebugBar.switchClass(ciDebugBar.icon, "debug-bar-dinlineBlock", "debug-bar-ndisplay");
263266
ciDebugBar.switchClass(ciDebugBar.toolbar, "debug-bar-ndisplay", "debug-bar-dinlineBlock");
264-
}
267+
}
265268
},
266269

267270
toggleViewsHints: function () {

system/HTTP/UserAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ protected function compileData()
278278
$this->setPlatform();
279279

280280
foreach (['setRobot', 'setBrowser', 'setMobile'] as $function) {
281-
if ($this->{$function}() === true) {
281+
if ($this->{$function}()) {
282282
break;
283283
}
284284
}

system/Log/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ protected function interpolate($message, array $context = [])
341341
$replace['{env}'] = ENVIRONMENT;
342342

343343
// Allow us to log the file/line that we are logging from
344-
if (str_contains($message, '{file}')) {
344+
if (str_contains($message, '{file}') || str_contains($message, '{line}')) {
345345
[$file, $line] = $this->determineFile();
346346

347347
$replace['{file}'] = $file;

system/Security/CheckPhpIni.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static function checkIni(?string $argument = null): array
135135
'date.timezone' => ['recommended' => 'UTC'],
136136
'mbstring.language' => ['recommended' => 'neutral'],
137137
'opcache.enable' => ['recommended' => '1'],
138-
'opcache.enable_cli' => ['recommended' => '1'],
138+
'opcache.enable_cli' => ['recommended' => '0', 'remark' => 'Enable when you are using queues or running repetitive CLI tasks'],
139139
'opcache.jit' => ['recommended' => 'tracing'],
140140
'opcache.jit_buffer_size' => ['recommended' => '128', 'remark' => 'Adjust with your free space of memory'],
141141
'zend.assertions' => ['recommended' => '-1'],
@@ -144,7 +144,7 @@ public static function checkIni(?string $argument = null): array
144144
if ($argument === 'opcache') {
145145
$items = [
146146
'opcache.enable' => ['recommended' => '1'],
147-
'opcache.enable_cli' => ['recommended' => '0', 'remark' => 'Enable when you using CLI'],
147+
'opcache.enable_cli' => ['recommended' => '0', 'remark' => 'Enable when you are using queues or running repetitive CLI tasks'],
148148
'opcache.jit' => ['recommended' => 'tracing', 'remark' => 'Disable when you used third-party extensions'],
149149
'opcache.jit_buffer_size' => ['recommended' => '128', 'remark' => 'Adjust with your free space of memory'],
150150
'opcache.memory_consumption' => ['recommended' => '128', 'remark' => 'Adjust with your free space of memory'],

tests/system/CodeIgniterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use CodeIgniter\Exceptions\PageNotFoundException;
2020
use CodeIgniter\HTTP\Method;
2121
use CodeIgniter\HTTP\Response;
22+
use CodeIgniter\HTTP\ResponseInterface;
2223
use CodeIgniter\Router\RouteCollection;
2324
use CodeIgniter\Test\CIUnitTestCase;
2425
use CodeIgniter\Test\Filters\CITestStreamFilter;
@@ -95,6 +96,7 @@ public function testRunEmptyDefaultRouteReturnResponse(): void
9596
$_SERVER['argc'] = 1;
9697

9798
$response = $this->codeigniter->run(null, true);
99+
$this->assertInstanceOf(ResponseInterface::class, $response);
98100

99101
$this->assertStringContainsString('Welcome to CodeIgniter', $response->getBody());
100102
}
@@ -159,6 +161,7 @@ public function testRun404OverrideControllerReturnsResponse(): void
159161
Services::injectMock('router', $router);
160162

161163
$response = $this->codeigniter->run($routes, true);
164+
$this->assertInstanceOf(ResponseInterface::class, $response);
162165

163166
$this->assertStringContainsString('Oops', $response->getBody());
164167
$this->assertSame(567, $response->getStatusCode());
@@ -177,6 +180,7 @@ public function testRun404OverrideReturnResponse(): void
177180
Services::injectMock('router', $router);
178181

179182
$response = $this->codeigniter->run($routes, true);
183+
$this->assertInstanceOf(ResponseInterface::class, $response);
180184

181185
$this->assertStringContainsString('Oops', $response->getBody());
182186
}
@@ -467,6 +471,7 @@ public function testRunForceSecure(): void
467471
$this->assertNull($response->header('Location'));
468472

469473
$response = $codeigniter->run(null, true);
474+
$this->assertInstanceOf(ResponseInterface::class, $response);
470475

471476
$this->assertSame('https://example.com/index.php/', $response->header('Location')->getValue());
472477
}

0 commit comments

Comments
 (0)