mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-14 16:06:26 +00:00
Php8.4 (#83)
* SessionHandlerAdapter for Cake's interface. * Removed deprecated E_STRICT.
This commit is contained in:
parent
789a752cf6
commit
5b6a1031bf
5 changed files with 51 additions and 64 deletions
54
.github/workflows/phpcs.yml
vendored
54
.github/workflows/phpcs.yml
vendored
|
@ -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
|
|
|
@ -59,6 +59,11 @@ It means that composer will look at `master` branch of repository configured und
|
||||||
|
|
||||||
## Changelog
|
## 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
|
### 2024-11-16
|
||||||
|
|
||||||
- Inflector fix: str_place with null.
|
- Inflector fix: str_place with null.
|
||||||
|
|
|
@ -302,10 +302,6 @@ class ErrorHandler {
|
||||||
$error = 'Notice';
|
$error = 'Notice';
|
||||||
$log = LOG_NOTICE;
|
$log = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
case E_STRICT:
|
|
||||||
$error = 'Strict';
|
|
||||||
$log = LOG_NOTICE;
|
|
||||||
break;
|
|
||||||
case E_DEPRECATED:
|
case E_DEPRECATED:
|
||||||
case E_USER_DEPRECATED:
|
case E_USER_DEPRECATED:
|
||||||
$error = 'Deprecated';
|
$error = 'Deprecated';
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
App::uses('Hash', 'Utility');
|
App::uses('Hash', 'Utility');
|
||||||
App::uses('Security', 'Utility');
|
App::uses('Security', 'Utility');
|
||||||
|
App::uses('SessionHandlerAdapter', 'Model/Datasource');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session class for CakePHP.
|
* Session class for CakePHP.
|
||||||
|
@ -591,12 +593,7 @@ class CakeSession {
|
||||||
$handler = static::_getHandler($sessionConfig['handler']['engine']);
|
$handler = static::_getHandler($sessionConfig['handler']['engine']);
|
||||||
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
|
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
|
||||||
session_set_save_handler(
|
session_set_save_handler(
|
||||||
array($handler, 'open'),
|
new SessionHandlerAdapter($handler)
|
||||||
array($handler, 'close'),
|
|
||||||
array($handler, 'read'),
|
|
||||||
array($handler, 'write'),
|
|
||||||
array($handler, 'destroy'),
|
|
||||||
array($handler, 'gc')
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
43
lib/Cake/Model/Datasource/SessionHandlerAdapter.php
Normal file
43
lib/Cake/Model/Datasource/SessionHandlerAdapter.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue