Php8.4 (#83)
Some checks failed
Tests / linux-tests (mysql, 8.0) (push) Has been cancelled
Tests / linux-tests (mysql, 8.1) (push) Has been cancelled
Tests / linux-tests (pgsql, 8.0) (push) Has been cancelled
Tests / linux-tests (sqlite, 8.0) (push) Has been cancelled

* SessionHandlerAdapter for Cake's interface.

* Removed deprecated E_STRICT.
This commit is contained in:
Kamil Wylegala 2025-02-04 22:29:07 +01:00 committed by GitHub
parent 789a752cf6
commit 5b6a1031bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 51 additions and 64 deletions

View file

@ -1,54 +0,0 @@
name: PHP Coding Standard
on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'
permissions:
contents: read
jobs:
phpcs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- '7.4'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
tools: composer
- name: Composer get cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-composer-
- name: Install Composer Packages
run: composer install --no-ansi --no-interaction --no-progress --ignore-platform-req=php
- name: Install CodeSniffer Rule
run: vendors/bin/phpcs --config-set installed_paths vendors/cakephp/cakephp-codesniffer
- name: Check CodeSniffer
run: vendors/bin/phpcs -p --extensions=php --standard=ruleset.xml ./lib/Cake

View file

@ -59,6 +59,11 @@ It means that composer will look at `master` branch of repository configured und
## Changelog
### 2025-02-04
- Fixes for PHP 8.4: `session_set_save_handler` accepts object, removed `E_STRICT` reference.
- Removed github action with php code sniffer. It's quite painful to work with. Need to migrate to something newer, that will affect code base as little as possible.
### 2024-11-16
- Inflector fix: str_place with null.

View file

@ -302,10 +302,6 @@ class ErrorHandler {
$error = 'Notice';
$log = LOG_NOTICE;
break;
case E_STRICT:
$error = 'Strict';
$log = LOG_NOTICE;
break;
case E_DEPRECATED:
case E_USER_DEPRECATED:
$error = 'Deprecated';

View file

@ -23,6 +23,8 @@
App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');
App::uses('SessionHandlerAdapter', 'Model/Datasource');
/**
* Session class for CakePHP.
@ -591,12 +593,7 @@ class CakeSession {
$handler = static::_getHandler($sessionConfig['handler']['engine']);
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
session_set_save_handler(
array($handler, 'open'),
array($handler, 'close'),
array($handler, 'read'),
array($handler, 'write'),
array($handler, 'destroy'),
array($handler, 'gc')
new SessionHandlerAdapter($handler)
);
}
}

View file

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
class SessionHandlerAdapter implements SessionHandlerInterface
{
public function __construct(
private CakeSessionHandlerInterface $cakeSessionHandler
) {
}
public function close()
{
return $this->cakeSessionHandler->close();
}
public function destroy(string $id)
{
return $this->cakeSessionHandler->destroy($id);
}
public function gc(int $max_lifetime)
{
return $this->cakeSessionHandler->gc($max_lifetime);
}
public function open(string $path, string $name)
{
//Cake interface ignores these parameters.
return $this->cakeSessionHandler->open();
}
public function read(string $id)
{
return $this->cakeSessionHandler->read($id);
}
public function write(string $id, string $data)
{
return $this->cakeSessionHandler->write($id, $data);
}
}