• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 21507617415

30 Jan 2026 07:11AM UTC coverage: 85.382% (-0.1%) from 85.527%
21507617415

push

github

web-flow
feat: FrankenPHP Worker Mode (#9889)

Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
Co-authored-by: neznaika0 <ozornick.ks@gmail.com>

153 of 243 new or added lines in 19 files covered. (62.96%)

1 existing line in 1 file now uncovered.

22119 of 25906 relevant lines covered (85.38%)

205.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/system/Session/PersistsConnection.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
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\Session;
15

16
/**
17
 * Trait for session handlers that need persistent connections.
18
 */
19
trait PersistsConnection
20
{
21
    /**
22
     * Connection pool keyed by connection identifier.
23
     * Allows multiple configurations to each have their own connection.
24
     *
25
     * @var array<string, object>
26
     */
27
    protected static $connectionPool = [];
28

29
    /**
30
     * Get connection identifier based on configuration.
31
     * This returns a unique hash for each distinct connection configuration.
32
     */
33
    protected function getConnectionIdentifier(): string
34
    {
35
        return hash('xxh128', serialize([
9✔
36
            'class'     => static::class,
9✔
37
            'savePath'  => $this->savePath,
9✔
38
            'keyPrefix' => $this->keyPrefix,
9✔
39
        ]));
9✔
40
    }
41

42
    /**
43
     * Check if a persistent connection exists for this configuration.
44
     */
45
    protected function hasPersistentConnection(): bool
46
    {
47
        $identifier = $this->getConnectionIdentifier();
9✔
48

49
        return isset(self::$connectionPool[$identifier]);
9✔
50
    }
51

52
    /**
53
     * Get the persistent connection for this configuration.
54
     */
55
    protected function getPersistentConnection(): ?object
56
    {
57
        $identifier = $this->getConnectionIdentifier();
2✔
58

59
        return self::$connectionPool[$identifier] ?? null;
2✔
60
    }
61

62
    /**
63
     * Store a connection for persistence.
64
     *
65
     * @param object|null $connection The connection to persist (null to clear).
66
     */
67
    protected function setPersistentConnection(?object $connection): void
68
    {
69
        $identifier = $this->getConnectionIdentifier();
9✔
70

71
        if ($connection === null) {
9✔
NEW
72
            unset(self::$connectionPool[$identifier]);
×
73
        } else {
74
            self::$connectionPool[$identifier] = $connection;
9✔
75
        }
76
    }
77

78
    /**
79
     * Reset all persistent connections (useful for testing).
80
     */
81
    public static function resetPersistentConnections(): void
82
    {
83
        self::$connectionPool = [];
22✔
84
    }
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc