From: Tim Düsterhus Date: Fri, 13 Aug 2021 08:45:58 +0000 (+0200) Subject: Fix PHP 8.1 compatibility in DatabaseObject::getDatabaseTableIndexName() X-Git-Tag: 5.4.5_RC_1~48 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ee2baf00fbe130faf911a9e398f6df7d2707153;p=GitHub%2FWoltLab%2FWCF.git Fix PHP 8.1 compatibility in DatabaseObject::getDatabaseTableIndexName() --- 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]; } /**