Skip to content

Commit cf32bb2

Browse files
committed
Rudimentary support for PHP 8.5
See #6490
1 parent 942d28c commit cf32bb2

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

wcfsetup/install/files/lib/data/menu/item/MenuItemNodeTree.class.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,14 @@ public function __construct($menuID, ?MenuItemList $menuItemList = null, $checkV
104104
}
105105

106106
// build menu structure
107-
foreach ($menuItemList as $menuItem) {
107+
foreach ($menuItemList->getObjects() as $menuItem) {
108108
$menuItem->cachePageObject();
109109

110110
$this->menuItems[$menuItem->itemID] = $menuItem;
111111

112-
if (!isset($this->menuItemStructure[$menuItem->parentItemID])) {
113-
$this->menuItemStructure[$menuItem->parentItemID] = [];
114-
}
115-
$this->menuItemStructure[$menuItem->parentItemID][] = $menuItem->itemID;
112+
$parentItemID = $menuItem->parentItemID ?? '';
113+
$this->menuItemStructure[$parentItemID] ??= [];
114+
$this->menuItemStructure[$parentItemID][] = $menuItem->itemID;
116115
}
117116

118117
// generate node tree
@@ -150,7 +149,7 @@ protected function generateNodeTree($parentID = null, ?MenuItemNode $parentNode
150149
{
151150
$nodes = [];
152151

153-
$itemIDs = ($this->menuItemStructure[$parentID] ?? []);
152+
$itemIDs = ($this->menuItemStructure[$parentID ?? ''] ?? []);
154153
foreach ($itemIDs as $itemID) {
155154
$menuItem = $this->menuItems[$itemID];
156155

wcfsetup/install/files/lib/data/page/PageCache.class.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ public function getPages()
4848

4949
/**
5050
* Returns a page by page id or null.
51-
*
52-
* @param int $pageID page id
53-
* @return Page|null
5451
*/
55-
public function getPage($pageID)
52+
public function getPage(?int $pageID): ?Page
5653
{
54+
if ($pageID === null) {
55+
return null;
56+
}
57+
5758
return $this->cache['pages'][$pageID] ?? null;
5859
}
5960

wcfsetup/install/files/lib/system/database/MySQLDatabase.class.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ public function connect()
3030

3131
try {
3232
$driverOptions = $this->defaultDriverOptions;
33-
$driverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'utf8mb4'";
33+
$initCommand = "SET NAMES 'utf8mb4'";
3434
if (!$this->failsafeTest) {
35-
$driverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'utf8mb4', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
35+
$initCommand = "SET NAMES 'utf8mb4', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'";
36+
}
37+
38+
if (\defined('\\Pdo\\Mysql::ATTR_INIT_COMMAND')) {
39+
// @phpstan-ignore class.notFound
40+
$driverOptions[\Pdo\Mysql::ATTR_INIT_COMMAND] = $initCommand;
41+
} else {
42+
$driverOptions[\PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
3643
}
3744

3845
// disable prepared statement emulation since MySQL 5.1.17 is the minimum required version
@@ -81,7 +88,13 @@ public static function isSupported()
8188
protected function setAttributes()
8289
{
8390
parent::setAttributes();
84-
$this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
91+
92+
if (\defined('\\Pdo\\Mysql::ATTR_USE_BUFFERED_QUERY')) {
93+
// @phpstan-ignore class.notFound
94+
$this->pdo->setAttribute(\Pdo\Mysql::ATTR_USE_BUFFERED_QUERY, true);
95+
} else {
96+
$this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
97+
}
8598
}
8699

87100
/**

0 commit comments

Comments
 (0)