Skip to content

Commit 9c94729

Browse files
authored
Merge branch 'codeigniter4:develop' into patch-9
2 parents c7d6825 + 482b8bb commit 9c94729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+271
-75
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check File Permissions
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
permission-check:
16+
name: Check File Permission
17+
runs-on: ubuntu-22.04
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Detect unnecessary execution permissions
24+
run: php utils/check_permission_x.php

admin/starter/tests/.htaccess

100755100644
File mode changed.

admin/starter/tests/index.html

100755100644
File mode changed.

app/Config/DocTypes.php

100755100644
File mode changed.

rector.php

-13
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@
4444
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
4545
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
4646
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
47-
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
4847
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
4948
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
5049
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
51-
use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector;
5250
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
5351
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
5452
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
@@ -107,7 +105,6 @@
107105
__DIR__ . '/tests/_support/Commands/Foobar.php',
108106
__DIR__ . '/tests/_support/View',
109107

110-
JsonThrowOnErrorRector::class,
111108
YieldDataProviderRector::class,
112109

113110
RemoveUnusedPromotedPropertyRector::class => [
@@ -174,16 +171,6 @@
174171
],
175172
MixedTypeRector::class,
176173

177-
// PHP 8.1 features but cause breaking changes
178-
FinalizePublicClassConstantRector::class => [
179-
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
180-
__DIR__ . '/system/Cache/Handlers/FileHandler.php',
181-
__DIR__ . '/system/CodeIgniter.php',
182-
__DIR__ . '/system/Events/Events.php',
183-
__DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php',
184-
__DIR__ . '/system/Log/Handlers/ErrorlogHandler.php',
185-
__DIR__ . '/system/Security/Security.php',
186-
],
187174
ReturnNeverTypeRector::class => [
188175
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
189176
__DIR__ . '/system/Cache/Handlers/MemcachedHandler.php',

system/Database/BaseConnection.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,12 @@ public function initialize()
420420
// Connect to the database and set the connection ID
421421
$this->connID = $this->connect($this->pConnect);
422422
} catch (Throwable $e) {
423-
$connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
423+
$this->connID = false;
424+
$connectionErrors[] = sprintf(
425+
'Main connection [%s]: %s',
426+
$this->DBDriver,
427+
$e->getMessage()
428+
);
424429
log_message('error', 'Error connecting to the database: ' . $e);
425430
}
426431

@@ -441,7 +446,12 @@ public function initialize()
441446
// Try to connect
442447
$this->connID = $this->connect($this->pConnect);
443448
} catch (Throwable $e) {
444-
$connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage());
449+
$connectionErrors[] = sprintf(
450+
'Failover #%d [%s]: %s',
451+
++$index,
452+
$this->DBDriver,
453+
$e->getMessage()
454+
);
445455
log_message('error', 'Error connecting to the database: ' . $e);
446456
}
447457

system/Database/Postgre/Connection.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,24 @@ public function connect(bool $persistent = false)
7878
$this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN);
7979

8080
if ($this->connID !== false) {
81-
if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false
81+
if (
82+
$persistent === true
83+
&& pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD
84+
&& pg_ping($this->connID) === false
8285
) {
83-
return false;
86+
$error = pg_last_error($this->connID);
87+
88+
throw new DatabaseException($error);
8489
}
8590

8691
if (! empty($this->schema)) {
8792
$this->simpleQuery("SET search_path TO {$this->schema},public");
8893
}
8994

9095
if ($this->setClientEncoding($this->charset) === false) {
91-
return false;
96+
$error = pg_last_error($this->connID);
97+
98+
throw new DatabaseException($error);
9299
}
93100
}
94101

system/Database/SQLSRV/Builder.php

100755100644
File mode changed.

system/Database/SQLSRV/Connection.php

100755100644
File mode changed.

system/Database/SQLSRV/Forge.php

100755100644
File mode changed.

system/Database/SQLSRV/PreparedQuery.php

100755100644
File mode changed.

system/Database/SQLSRV/Result.php

100755100644
File mode changed.

system/Database/SQLSRV/Utils.php

100755100644
File mode changed.

system/HTTP/IncomingRequest.php

100755100644
File mode changed.

system/Helpers/cookie_helper.php

100755100644
File mode changed.

system/Helpers/html_helper.php

100755100644
File mode changed.

system/Helpers/inflector_helper.php

100755100644
File mode changed.

system/Helpers/text_helper.php

100755100644
File mode changed.

system/Test/Mock/MockResponse.php

100755100644
File mode changed.

system/Test/PhpStreamWrapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static function restore()
4646
stream_wrapper_restore('php');
4747
}
4848

49-
public function stream_open(string $path): bool
49+
public function stream_open(): bool
5050
{
5151
return true;
5252
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of CodeIgniter 4 framework.
7+
*
8+
* (c) CodeIgniter Foundation <[email protected]>
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
namespace CodeIgniter\Database\Live\Postgre;
15+
16+
use CodeIgniter\Database\Exceptions\DatabaseException;
17+
use CodeIgniter\Test\CIUnitTestCase;
18+
use Config\Database;
19+
use PHPUnit\Framework\Attributes\Group;
20+
21+
/**
22+
* @internal
23+
*/
24+
#[Group('DatabaseLive')]
25+
final class ConnectTest extends CIUnitTestCase
26+
{
27+
protected function setUp(): void
28+
{
29+
parent::setUp();
30+
31+
$this->db = Database::connect($this->DBGroup);
32+
33+
if ($this->db->DBDriver !== 'Postgre') {
34+
$this->markTestSkipped('This test is only for Postgre.');
35+
}
36+
}
37+
38+
public function testShowErrorMessageWhenSettingInvalidCharset(): void
39+
{
40+
$this->expectException(DatabaseException::class);
41+
$this->expectExceptionMessage(
42+
'Unable to connect to the database.
43+
Main connection [Postgre]: ERROR: invalid value for parameter "client_encoding": "utf8mb4"'
44+
);
45+
46+
$config = config('Database');
47+
$group = $config->tests;
48+
// Sets invalid charset.
49+
$group['charset'] = 'utf8mb4';
50+
$db = Database::connect($group);
51+
52+
// Actually connect to DB.
53+
$db->initialize();
54+
}
55+
}

tests/system/Helpers/CookieHelperTest.php

100755100644
File mode changed.

tests/system/Helpers/HTMLHelperTest.php

100755100644
File mode changed.

tests/system/Helpers/InflectorHelperTest.php

100755100644
File mode changed.

tests/system/Helpers/NumberHelperTest.php

100755100644
File mode changed.

tests/system/Helpers/TextHelperTest.php

100755100644
File mode changed.

user_guide_src/source/_static/css/citheme.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(
245245
background-color: #fffff0;
246246
}
247247

248-
span.std {
248+
span.std,
249+
span.pre {
249250
text-wrap: nowrap;
250251
}
251252

user_guide_src/source/database/query_builder.rst

100755100644
File mode changed.

user_guide_src/source/general/common_functions.rst

100755100644
File mode changed.

user_guide_src/source/helpers/cookie_helper.rst

100755100644
File mode changed.

user_guide_src/source/helpers/html_helper.rst

100755100644
File mode changed.

user_guide_src/source/helpers/inflector_helper.rst

100755100644
File mode changed.

user_guide_src/source/helpers/text_helper.rst

100755100644
File mode changed.

user_guide_src/source/libraries/caching.rst

+8-13
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ to projects and modules. This will replace the hard-coded value in a future rele
6262
$file
6363
=====
6464

65-
This is an array of settings specific to the ``File`` handler to determine how it should save the cache files.
65+
This is an array of settings specific to the **File** handler to determine how it should save the cache files.
6666

6767
$memcached
6868
==========
6969

70-
This is an array of servers that will be used when using the ``Memcache(d)`` handler.
70+
This is an array of servers that will be used when using the **Memcached** handler.
7171

7272
$redis
7373
======
7474

75-
The settings for the Redis server that you wish to use when using the ``Redis`` and ``Predis`` handler.
75+
The settings for the Redis server that you wish to use when using the **Redis** and **Predis** handler.
7676

7777
******************
7878
Command-Line Tools
@@ -139,12 +139,11 @@ Class Reference
139139
Gets an item from the cache. If ``null`` was returned, this will invoke the callback
140140
and save the result. Either way, this will return the value.
141141

142-
.. php:method:: save(string $key, $data[, int $ttl = 60[, $raw = false]])
142+
.. php:method:: save(string $key, $data[, int $ttl = 60])
143143
144144
:param string $key: Cache item name
145145
:param mixed $data: the data to save
146146
:param int $ttl: Time To Live, in seconds (default 60)
147-
:param bool $raw: Whether to store the raw value
148147
:returns: ``true`` on success, ``false`` on failure
149148
:rtype: bool
150149

@@ -155,9 +154,6 @@ Class Reference
155154

156155
.. literalinclude:: caching/004.php
157156

158-
.. note:: The ``$raw`` parameter is only utilized by Memcache,
159-
in order to allow usage of ``increment()`` and ``decrement()``.
160-
161157
.. php:method:: delete($key): bool
162158
163159
:param string $key: name of cached item
@@ -280,11 +276,10 @@ Drivers
280276
File-based Caching
281277
==================
282278

283-
Unlike caching from the Output Class, the driver file-based caching
284-
allows for pieces of view files to be cached. Use this with care, and
285-
make sure to benchmark your application, as a point can come where disk
286-
I/O will negate positive gains by caching. This requires a cache
287-
directory to be really writable by the application.
279+
This requires a cache directory to be really writable by the application.
280+
281+
Use this with care, and make sure to benchmark your application, as a point can
282+
come where disk I/O will negate positive gains by caching.
288283

289284
Memcached Caching
290285
=================

0 commit comments

Comments
 (0)