|
57 | 57 | */ |
58 | 58 | class Relation |
59 | 59 | { |
60 | | - /** @var RelationParameters[] $cache */ |
61 | | - private static array $cache = []; |
| 60 | + private static RelationParameters|null $cache = null; |
62 | 61 |
|
63 | 62 | public function __construct(public DatabaseInterface $dbi) |
64 | 63 | { |
65 | 64 | } |
66 | 65 |
|
67 | 66 | public function getRelationParameters(): RelationParameters |
68 | 67 | { |
69 | | - $server = $GLOBALS['server']; |
70 | | - |
71 | | - if (isset(self::$cache[$server])) { |
72 | | - return self::$cache[$server]; |
73 | | - } |
74 | | - |
75 | | - if (! isset($_SESSION['relation']) || ! is_array($_SESSION['relation'])) { |
76 | | - $_SESSION['relation'] = []; |
| 68 | + if (self::$cache === null) { |
| 69 | + self::$cache = RelationParameters::fromArray($this->checkRelationsParam()); |
77 | 70 | } |
78 | 71 |
|
79 | | - if ( |
80 | | - isset($_SESSION['relation'][$server]) && is_array($_SESSION['relation'][$server]) |
81 | | - && isset($_SESSION['relation'][$server]['version']) |
82 | | - && $_SESSION['relation'][$server]['version'] === Version::VERSION |
83 | | - ) { |
84 | | - self::$cache[$server] = RelationParameters::fromArray($_SESSION['relation'][$server]); |
85 | | - |
86 | | - return self::$cache[$server]; |
87 | | - } |
88 | | - |
89 | | - self::$cache[$server] = RelationParameters::fromArray($this->checkRelationsParam()); |
90 | | - $_SESSION['relation'][$server] = self::$cache[$server]->toArray(); |
91 | | - |
92 | | - return self::$cache[$server]; |
| 72 | + return self::$cache; |
93 | 73 | } |
94 | 74 |
|
95 | 75 | /** |
@@ -1510,8 +1490,7 @@ public function createPmaDatabase(string $configurationStorageDbName): bool |
1510 | 1490 | // Re-build the cache to show the list of tables created or not |
1511 | 1491 | // This is the case when the DB could be created but no tables just after |
1512 | 1492 | // So just purge the cache and show the new configuration storage state |
1513 | | - unset($_SESSION['relation'][$GLOBALS['server']]); |
1514 | | - unset(self::$cache[$GLOBALS['server']]); |
| 1493 | + self::$cache = null; |
1515 | 1494 | $this->getRelationParameters(); |
1516 | 1495 |
|
1517 | 1496 | return true; |
@@ -1625,8 +1604,7 @@ public function fixPmaTables(string $db, bool $create = true): void |
1625 | 1604 |
|
1626 | 1605 | //NOTE: I am unsure why we do that, as it defeats the purpose of the session cache |
1627 | 1606 | // Unset the cache |
1628 | | - unset($_SESSION['relation'][$GLOBALS['server']]); |
1629 | | - unset(self::$cache[$GLOBALS['server']]); |
| 1607 | + self::$cache = null; |
1630 | 1608 | // Fill back the cache |
1631 | 1609 | $this->getRelationParameters(); |
1632 | 1610 | } |
|
0 commit comments