Skip to content

Commit

Permalink
Merge branch 'codeigniter4:develop' into patch-9
Browse files Browse the repository at this point in the history
  • Loading branch information
obozdag authored Jun 1, 2024
2 parents c7d6825 + 482b8bb commit 9c94729
Show file tree
Hide file tree
Showing 48 changed files with 271 additions and 75 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test-file-permissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check File Permissions

on:
pull_request:
push:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
permission-check:
name: Check File Permission
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect unnecessary execution permissions
run: php utils/check_permission_x.php
Empty file modified admin/starter/tests/.htaccess
100755 → 100644
Empty file.
Empty file modified admin/starter/tests/index.html
100755 → 100644
Empty file.
Empty file modified app/Config/DocTypes.php
100755 → 100644
Empty file.
13 changes: 0 additions & 13 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
Expand Down Expand Up @@ -107,7 +105,6 @@
__DIR__ . '/tests/_support/Commands/Foobar.php',
__DIR__ . '/tests/_support/View',

JsonThrowOnErrorRector::class,
YieldDataProviderRector::class,

RemoveUnusedPromotedPropertyRector::class => [
Expand Down Expand Up @@ -174,16 +171,6 @@
],
MixedTypeRector::class,

// PHP 8.1 features but cause breaking changes
FinalizePublicClassConstantRector::class => [
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
__DIR__ . '/system/Cache/Handlers/FileHandler.php',
__DIR__ . '/system/CodeIgniter.php',
__DIR__ . '/system/Events/Events.php',
__DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php',
__DIR__ . '/system/Log/Handlers/ErrorlogHandler.php',
__DIR__ . '/system/Security/Security.php',
],
ReturnNeverTypeRector::class => [
__DIR__ . '/system/Cache/Handlers/BaseHandler.php',
__DIR__ . '/system/Cache/Handlers/MemcachedHandler.php',
Expand Down
14 changes: 12 additions & 2 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,12 @@ public function initialize()
// Connect to the database and set the connection ID
$this->connID = $this->connect($this->pConnect);
} catch (Throwable $e) {
$connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
$this->connID = false;
$connectionErrors[] = sprintf(
'Main connection [%s]: %s',
$this->DBDriver,
$e->getMessage()
);
log_message('error', 'Error connecting to the database: ' . $e);
}

Expand All @@ -441,7 +446,12 @@ public function initialize()
// Try to connect
$this->connID = $this->connect($this->pConnect);
} catch (Throwable $e) {
$connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage());
$connectionErrors[] = sprintf(
'Failover #%d [%s]: %s',
++$index,
$this->DBDriver,
$e->getMessage()
);
log_message('error', 'Error connecting to the database: ' . $e);
}

Expand Down
13 changes: 10 additions & 3 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,24 @@ public function connect(bool $persistent = false)
$this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN);

if ($this->connID !== false) {
if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false
if (
$persistent === true
&& pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD
&& pg_ping($this->connID) === false
) {
return false;
$error = pg_last_error($this->connID);

throw new DatabaseException($error);
}

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

if ($this->setClientEncoding($this->charset) === false) {
return false;
$error = pg_last_error($this->connID);

throw new DatabaseException($error);
}
}

Expand Down
Empty file modified system/Database/SQLSRV/Builder.php
100755 → 100644
Empty file.
Empty file modified system/Database/SQLSRV/Connection.php
100755 → 100644
Empty file.
Empty file modified system/Database/SQLSRV/Forge.php
100755 → 100644
Empty file.
Empty file modified system/Database/SQLSRV/PreparedQuery.php
100755 → 100644
Empty file.
Empty file modified system/Database/SQLSRV/Result.php
100755 → 100644
Empty file.
Empty file modified system/Database/SQLSRV/Utils.php
100755 → 100644
Empty file.
Empty file modified system/HTTP/IncomingRequest.php
100755 → 100644
Empty file.
Empty file modified system/Helpers/cookie_helper.php
100755 → 100644
Empty file.
Empty file modified system/Helpers/html_helper.php
100755 → 100644
Empty file.
Empty file modified system/Helpers/inflector_helper.php
100755 → 100644
Empty file.
Empty file modified system/Helpers/text_helper.php
100755 → 100644
Empty file.
Empty file modified system/Test/Mock/MockResponse.php
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion system/Test/PhpStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function restore()
stream_wrapper_restore('php');
}

public function stream_open(string $path): bool
public function stream_open(): bool
{
return true;
}
Expand Down
55 changes: 55 additions & 0 deletions tests/system/Database/Live/Postgre/ConnectTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace CodeIgniter\Database\Live\Postgre;

use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Database;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[Group('DatabaseLive')]
final class ConnectTest extends CIUnitTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->db = Database::connect($this->DBGroup);

if ($this->db->DBDriver !== 'Postgre') {
$this->markTestSkipped('This test is only for Postgre.');
}
}

public function testShowErrorMessageWhenSettingInvalidCharset(): void
{
$this->expectException(DatabaseException::class);
$this->expectExceptionMessage(
'Unable to connect to the database.
Main connection [Postgre]: ERROR: invalid value for parameter "client_encoding": "utf8mb4"'
);

$config = config('Database');
$group = $config->tests;
// Sets invalid charset.
$group['charset'] = 'utf8mb4';
$db = Database::connect($group);

// Actually connect to DB.
$db->initialize();
}
}
Empty file modified tests/system/Helpers/CookieHelperTest.php
100755 → 100644
Empty file.
Empty file modified tests/system/Helpers/HTMLHelperTest.php
100755 → 100644
Empty file.
Empty file modified tests/system/Helpers/InflectorHelperTest.php
100755 → 100644
Empty file.
Empty file modified tests/system/Helpers/NumberHelperTest.php
100755 → 100644
Empty file.
Empty file modified tests/system/Helpers/TextHelperTest.php
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion user_guide_src/source/_static/css/citheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(
background-color: #fffff0;
}

span.std {
span.std,
span.pre {
text-wrap: nowrap;
}

Expand Down
Empty file modified user_guide_src/source/database/query_builder.rst
100755 → 100644
Empty file.
Empty file modified user_guide_src/source/general/common_functions.rst
100755 → 100644
Empty file.
Empty file modified user_guide_src/source/helpers/cookie_helper.rst
100755 → 100644
Empty file.
Empty file modified user_guide_src/source/helpers/html_helper.rst
100755 → 100644
Empty file.
Empty file modified user_guide_src/source/helpers/inflector_helper.rst
100755 → 100644
Empty file.
Empty file modified user_guide_src/source/helpers/text_helper.rst
100755 → 100644
Empty file.
21 changes: 8 additions & 13 deletions user_guide_src/source/libraries/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ to projects and modules. This will replace the hard-coded value in a future rele
$file
=====

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

$memcached
==========

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

$redis
======

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

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

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

Expand All @@ -155,9 +154,6 @@ Class Reference

.. literalinclude:: caching/004.php

.. note:: The ``$raw`` parameter is only utilized by Memcache,
in order to allow usage of ``increment()`` and ``decrement()``.

.. php:method:: delete($key): bool
:param string $key: name of cached item
Expand Down Expand Up @@ -280,11 +276,10 @@ Drivers
File-based Caching
==================

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

Use this with care, and make sure to benchmark your application, as a point can
come where disk I/O will negate positive gains by caching.

Memcached Caching
=================
Expand Down
Loading

0 comments on commit 9c94729

Please sign in to comment.