Skip to content

Commit ee1aaf6

Browse files
authored
Merge pull request #15 from HaiTo/work/upgrade-for-php84
patch from kamilwylegala#83
2 parents 53b54f5 + f9dc42f commit ee1aaf6

5 files changed

Lines changed: 51 additions & 64 deletions

File tree

.github/workflows/phpcs.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ It means that composer will look at `master` branch of repository configured und
5959

6060
## Changelog
6161

62+
### 2025-02-04
63+
64+
- Fixes for PHP 8.4: `session_set_save_handler` accepts object, removed `E_STRICT` reference.
65+
- 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.
66+
6267
### 2024-11-16
6368

6469
- Inflector fix: str_place with null.

lib/Cake/Error/ErrorHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ public static function mapErrorCode($code) {
302302
$error = 'Notice';
303303
$log = LOG_NOTICE;
304304
break;
305-
case E_STRICT:
306-
$error = 'Strict';
307-
$log = LOG_NOTICE;
308-
break;
309305
case E_DEPRECATED:
310306
case E_USER_DEPRECATED:
311307
$error = 'Deprecated';

lib/Cake/Model/Datasource/CakeSession.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
App::uses('Hash', 'Utility');
2525
App::uses('Security', 'Utility');
26+
App::uses('SessionHandlerAdapter', 'Model/Datasource');
27+
2628

2729
/**
2830
* Session class for CakePHP.
@@ -591,12 +593,7 @@ protected static function _configureSession() {
591593
$handler = static::_getHandler($sessionConfig['handler']['engine']);
592594
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
593595
session_set_save_handler(
594-
array($handler, 'open'),
595-
array($handler, 'close'),
596-
array($handler, 'read'),
597-
array($handler, 'write'),
598-
array($handler, 'destroy'),
599-
array($handler, 'gc')
596+
new SessionHandlerAdapter($handler)
600597
);
601598
}
602599
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
class SessionHandlerAdapter implements SessionHandlerInterface
6+
{
7+
8+
public function __construct(
9+
private CakeSessionHandlerInterface $cakeSessionHandler
10+
) {
11+
}
12+
13+
public function close()
14+
{
15+
return $this->cakeSessionHandler->close();
16+
}
17+
18+
public function destroy(string $id)
19+
{
20+
return $this->cakeSessionHandler->destroy($id);
21+
}
22+
23+
public function gc(int $max_lifetime)
24+
{
25+
return $this->cakeSessionHandler->gc($max_lifetime);
26+
}
27+
28+
public function open(string $path, string $name)
29+
{
30+
//Cake interface ignores these parameters.
31+
return $this->cakeSessionHandler->open();
32+
}
33+
34+
public function read(string $id)
35+
{
36+
return $this->cakeSessionHandler->read($id);
37+
}
38+
39+
public function write(string $id, string $data)
40+
{
41+
return $this->cakeSessionHandler->write($id, $data);
42+
}
43+
}

0 commit comments

Comments
 (0)