From 8ee2baf00fbe130faf911a9e398f6df7d2707153 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 13 Aug 2021 10:45:58 +0200 Subject: [PATCH] Fix PHP 8.1 compatibility in DatabaseObject::getDatabaseTableIndexName() --- .../install/files/lib/data/DatabaseObject.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/data/DatabaseObject.class.php b/wcfsetup/install/files/lib/data/DatabaseObject.class.php index 3c0aae5ddf..602a635eb5 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObject.class.php @@ -203,19 +203,20 @@ abstract class DatabaseObject implements IIDObject, IStorableObject return static::$databaseTableIndexName; } - static $databaseTableIndexName = null; - if ($databaseTableIndexName === null) { - $className = \explode('\\', \get_called_class()); + $className = \get_called_class(); + static $databaseTableIndexNames = []; + if (!isset($databaseTableIndexNames[$className])) { + $classParts = \explode('\\', $className); $parts = \preg_split( '~(?=[A-Z](?=[a-z]))~', - \array_pop($className), + \array_pop($classParts), -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY ); - $databaseTableIndexName = \strtolower(\array_pop($parts)) . 'ID'; + $databaseTableIndexNames[$className] = \strtolower(\array_pop($parts)) . 'ID'; } - return $databaseTableIndexName; + return $databaseTableIndexNames[$className]; } /** -- 2.20.1