From 5e9aea0af4d922512bee1d158a1ae4a8ef12e526 Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Sat, 18 Nov 2023 02:35:42 +0100 Subject: [PATCH] [5.0] Fix legacy table creation (#42180) * Fix legacy table creation If a legacy table is created by Table::getInstance() twice it fails the second time. Reason for this is that the legacy table name is not used if the table class already exists. --- libraries/src/Table/Table.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libraries/src/Table/Table.php b/libraries/src/Table/Table.php index 934409e324b61..614a504ee24d3 100644 --- a/libraries/src/Table/Table.php +++ b/libraries/src/Table/Table.php @@ -315,21 +315,21 @@ public static function getInstance($type, $prefix = 'JTable', $config = []) include_once $tryThis; } } + } - if (!class_exists($tableClass) && class_exists($tableClassLegacy)) { - $tableClass = $tableClassLegacy; - } + if (!class_exists($tableClass) && class_exists($tableClassLegacy)) { + $tableClass = $tableClassLegacy; + } - if (!class_exists($tableClass)) { - /* - * If unable to find the class file in the Table include paths. Return false. - * The warning JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND has been removed in 3.6.3. - * In 4.0 an Exception (type to be determined) will be thrown. - * For more info see https://github.com/joomla/joomla-cms/issues/11570 - */ + if (!class_exists($tableClass)) { + /* + * If unable to find the class file in the Table include paths. Return false. + * The warning JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND has been removed in 3.6.3. + * In 6.0 an Exception (type to be determined) will be thrown. + * For more info see https://github.com/joomla/joomla-cms/issues/11570 + */ - return false; - } + return false; } // If a database object was passed in the configuration array use it, otherwise get the global one from Factory.