Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2c338db
Add compatibility plugin and move classmap
HLeithner Mar 12, 2023
7706768
cs
HLeithner Mar 12, 2023
4722438
remove classmap from unit tests
HLeithner Mar 12, 2023
2365f4e
Use namespace for html helper tests
HLeithner Mar 12, 2023
590718d
PoC for Table::getInstance JTable prefix
HLeithner Mar 12, 2023
b940e4f
Revert cache plugin change
HLeithner Mar 12, 2023
6c966ce
PoC HTMLHelper correct namespace
HLeithner Mar 13, 2023
f6f7d5b
Merge branch '5.0-dev' into 5/feature/bc-plugin
HLeithner May 26, 2023
a4bd6d3
revert drone change
HLeithner May 27, 2023
22b72a6
Activate the plugin by default on new installations
HLeithner May 27, 2023
1ddc987
Fix system plugins ordering in base.sql
richard67 May 27, 2023
11750a6
Add insert of extension to update SQL
richard67 May 27, 2023
8b35008
Add to core plugins in ExtensionHelper
richard67 May 27, 2023
50333f8
Merge pull request #56 from richard67/5.0-dev-hleithner-5-feature-bc-…
HLeithner May 27, 2023
484628b
Replace JTable references, revert Table::getInstance logic
HLeithner May 27, 2023
7271e1b
Add Table::getInstance JTable logic including explanation
HLeithner May 27, 2023
34c6818
Cleanup plugin
HLeithner May 28, 2023
1d60853
Disable again for new installations
HLeithner May 28, 2023
a9bc360
Merge branch '5.0-dev' into 5/feature/bc-plugin
HLeithner May 29, 2023
dc1eafb
Merge branch '5.0-dev' into 5/feature/bc-plugin
HLeithner May 29, 2023
8694f73
Merge branch '5.0-dev' into 5/feature/bc-plugin
HLeithner May 29, 2023
6aa1a79
Merge branch '5.0-dev' into 5/feature/bc-plugin
HLeithner Jun 26, 2023
baab18a
Merge branch '5.0-dev' into 5/feature/bc-plugin
Jul 2, 2023
3c9dc5e
Merge remote-tracking branch 'upstream/5.0-dev' into 5/feature/bc-plugin
HLeithner Jul 3, 2023
2db62d4
Activate B/C plugin on new installation
HLeithner Jul 3, 2023
3b19bfb
Initialise the Extension table with the real database object
HLeithner Jul 3, 2023
0459a3f
Support custom database object on language load
HLeithner Jul 3, 2023
c4a2b3f
Fix wrong function usage
HLeithner Jul 3, 2023
4225a05
Add renamed non PascalCase table aliases and fix occurrence
HLeithner Jul 3, 2023
d9d1311
Disable plugin on new installations again
HLeithner Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
DROP TABLE IF EXISTS `#__utf8_conversion`;

INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
(0, 'plg_system_compat', 'plugin', 'compat', 'system', 0, 1, 1, 0, 1, '', '{"classes_aliases":"1"}', '', 0, 0);
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
DROP TABLE IF EXISTS "#__utf8_conversion";

INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_system_compat', 'plugin', 'compat', 'system', 0, 1, 1, 0, 1, '', '{"classes_aliases":"1"}', '', 0, 0);
9 changes: 9 additions & 0 deletions administrator/language/en-GB/plg_system_compat.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Joomla! Project
; (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_COMPAT_FIELD_CLASSES_ALIASES_LABEL="Classes Aliases"
PLG_COMPAT_FIELD_CLASSES_ALIASES_DESCRIPTION="Add class aliases for classes which have been renamed or moved to a namespace."
PLG_COMAPT_XML_DESCRIPTION="Provides backward compatibility to the prior major version."
PLG_SYSTEM_COMAPT="System - Backward Compatibility"
7 changes: 7 additions & 0 deletions administrator/language/en-GB/plg_system_compat.sys.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; Joomla! Project
; (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
; License GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

PLG_COMAPT_XML_DESCRIPTION="Provides backward compatibility to the prior major version."
PLG_SYSTEM_COMAPT="System - Backward Compatibility"
45 changes: 23 additions & 22 deletions installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -333,28 +333,29 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
(0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0),
(0, 'plg_system_debug', 'plugin', 'debug', 'system', 0, 1, 1, 0, 1, '', '{"profile":"1","queries":"1","memory":"1","language_files":"1","language_strings":"1","strip-first":"1","strip-prefix":"","strip-suffix":""}', '', 4, 0),
(0, 'plg_system_fields', 'plugin', 'fields', 'system', 0, 1, 1, 0, 1, '', '', '', 5, 0),
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, 1, '', '', '', 6, 0),
(0, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 1, 1, 0, 1, '', '{}', '', 7, 0),
(0, 'plg_system_jooa11y', 'plugin', 'jooa11y', 'system', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_system_languagecode', 'plugin', 'languagecode', 'system', 0, 0, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_system_languagefilter', 'plugin', 'languagefilter', 'system', 0, 0, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_system_log', 'plugin', 'log', 'system', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_system_logout', 'plugin', 'logout', 'system', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_system_logrotation', 'plugin', 'logrotation', 'system', 0, 1, 1, 0, 1, '', '{}', '', 13, 0),
(0, 'plg_system_privacyconsent', 'plugin', 'privacyconsent', 'system', 0, 0, 1, 0, 1, '', '{}', '', 14, 0),
(0, 'plg_system_redirect', 'plugin', 'redirect', 'system', 0, 0, 1, 0, 1, '', '', '', 15, 0),
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 17, 0),
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 0, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 20, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 21, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 22, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
(0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 24, 0),
(0, 'plg_system_compat', 'plugin', 'compat', 'system', 0, 1, 1, 0, 1, '', '{"classes_aliases":"1"}', '', 4, 0),
(0, 'plg_system_debug', 'plugin', 'debug', 'system', 0, 1, 1, 0, 1, '', '{"profile":"1","queries":"1","memory":"1","language_files":"1","language_strings":"1","strip-first":"1","strip-prefix":"","strip-suffix":""}', '', 5, 0),
(0, 'plg_system_fields', 'plugin', 'fields', 'system', 0, 1, 1, 0, 1, '', '', '', 6, 0),
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, 1, '', '', '', 7, 0),
(0, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 1, 1, 0, 1, '', '{}', '', 8, 0),
(0, 'plg_system_jooa11y', 'plugin', 'jooa11y', 'system', 0, 1, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_system_languagecode', 'plugin', 'languagecode', 'system', 0, 0, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_system_languagefilter', 'plugin', 'languagefilter', 'system', 0, 0, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_system_log', 'plugin', 'log', 'system', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_system_logout', 'plugin', 'logout', 'system', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_system_logrotation', 'plugin', 'logrotation', 'system', 0, 1, 1, 0, 1, '', '{}', '', 14, 0),
(0, 'plg_system_privacyconsent', 'plugin', 'privacyconsent', 'system', 0, 0, 1, 0, 1, '', '{}', '', 15, 0),
(0, 'plg_system_redirect', 'plugin', 'redirect', 'system', 0, 0, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 18, 0),
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 20, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 21, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 24, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 25, 0),
(0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 26, 0),
(0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_task_demotasks', 'plugin', 'demotasks', 'task', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
(0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0),
Expand Down
45 changes: 23 additions & 22 deletions installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -339,28 +339,29 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'plg_system_accessibility', 'plugin', 'accessibility', 'system', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_system_actionlogs', 'plugin', 'actionlogs', 'system', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
(0, 'plg_system_cache', 'plugin', 'cache', 'system', 0, 0, 1, 0, 1, '', '{"browsercache":"0","cachetime":"15"}', '', 3, 0),
(0, 'plg_system_debug', 'plugin', 'debug', 'system', 0, 1, 1, 0, 1, '', '{"profile":"1","queries":"1","memory":"1","language_files":"1","language_strings":"1","strip-first":"1","strip-prefix":"","strip-suffix":""}', '', 4, 0),
(0, 'plg_system_fields', 'plugin', 'fields', 'system', 0, 1, 1, 0, 1, '', '', '', 5, 0),
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, 1, '', '', '', 6, 0),
(0, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 1, 1, 0, 1, '', '{}', '', 7, 0),
(0, 'plg_system_jooa11y', 'plugin', 'jooa11y', 'system', 0, 1, 1, 0, 1, '', '', '', 8, 0),
(0, 'plg_system_languagecode', 'plugin', 'languagecode', 'system', 0, 0, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_system_languagefilter', 'plugin', 'languagefilter', 'system', 0, 0, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_system_log', 'plugin', 'log', 'system', 0, 1, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_system_logout', 'plugin', 'logout', 'system', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_system_logrotation', 'plugin', 'logrotation', 'system', 0, 1, 1, 0, 1, '', '{}', '', 13, 0),
(0, 'plg_system_privacyconsent', 'plugin', 'privacyconsent', 'system', 0, 0, 1, 0, 1, '', '{}', '', 14, 0),
(0, 'plg_system_redirect', 'plugin', 'redirect', 'system', 0, 0, 1, 0, 1, '', '', '', 15, 0),
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 17, 0),
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 18, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 0, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 20, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 21, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 22, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
(0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 24, 0),
(0, 'plg_system_compat', 'plugin', 'compat', 'system', 0, 1, 1, 0, 1, '', '{"classes_aliases":"1"}', '', 4, 0),
(0, 'plg_system_debug', 'plugin', 'debug', 'system', 0, 1, 1, 0, 1, '', '{"profile":"1","queries":"1","memory":"1","language_files":"1","language_strings":"1","strip-first":"1","strip-prefix":"","strip-suffix":""}', '', 5, 0),
(0, 'plg_system_fields', 'plugin', 'fields', 'system', 0, 1, 1, 0, 1, '', '', '', 6, 0),
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, 1, '', '', '', 7, 0),
(0, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 1, 1, 0, 1, '', '{}', '', 8, 0),
(0, 'plg_system_jooa11y', 'plugin', 'jooa11y', 'system', 0, 1, 1, 0, 1, '', '', '', 9, 0),
(0, 'plg_system_languagecode', 'plugin', 'languagecode', 'system', 0, 0, 1, 0, 1, '', '', '', 10, 0),
(0, 'plg_system_languagefilter', 'plugin', 'languagefilter', 'system', 0, 0, 1, 0, 1, '', '', '', 11, 0),
(0, 'plg_system_log', 'plugin', 'log', 'system', 0, 1, 1, 0, 1, '', '', '', 12, 0),
(0, 'plg_system_logout', 'plugin', 'logout', 'system', 0, 1, 1, 0, 1, '', '', '', 13, 0),
(0, 'plg_system_logrotation', 'plugin', 'logrotation', 'system', 0, 1, 1, 0, 1, '', '{}', '', 14, 0),
(0, 'plg_system_privacyconsent', 'plugin', 'privacyconsent', 'system', 0, 0, 1, 0, 1, '', '{}', '', 15, 0),
(0, 'plg_system_redirect', 'plugin', 'redirect', 'system', 0, 0, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 17, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 18, 0),
(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '', '', 19, 0),
(0, 'plg_system_sessiongc', 'plugin', 'sessiongc', 'system', 0, 1, 1, 0, 1, '', '', '', 20, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 21, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 24, 0),
(0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 25, 0),
(0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 26, 0),
(0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
(0, 'plg_task_demotasks', 'plugin', 'demotasks', 'task', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
(0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0),
Expand Down
3 changes: 0 additions & 3 deletions libraries/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class_exists('\\Joomla\\CMS\\Autoload\\ClassLoader');
// Decorate Composer autoloader
spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true);

// Register the class aliases for Framework classes that have replaced their Platform equivalents
require_once JPATH_LIBRARIES . '/classmap.php';

/**
* Register the global exception handler. And set error level to server default error level.
* The error level may be changed later in boot up process, after application config will be loaded.
Expand Down
3 changes: 0 additions & 3 deletions libraries/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class_exists('\\Joomla\\CMS\\Autoload\\ClassLoader');
// Decorate Composer autoloader
spl_autoload_register([new \Joomla\CMS\Autoload\ClassLoader($loader), 'loadClass'], true, true);

// Register the class aliases for Framework classes that have replaced their Platform equivalents
require_once JPATH_LIBRARIES . '/classmap.php';

// Suppress phar stream wrapper for non .phar files
$behavior = new \TYPO3\PharStreamWrapper\Behavior();
\TYPO3\PharStreamWrapper\Manager::initialize(
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Extension/ExtensionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class ExtensionHelper
['plugin', 'accessibility', 'system', 0],
['plugin', 'actionlogs', 'system', 0],
['plugin', 'cache', 'system', 0],
['plugin', 'compat', 'system', 0],
['plugin', 'debug', 'system', 0],
['plugin', 'fields', 'system', 0],
['plugin', 'guidedtours', 'system', 0],
Expand Down
8 changes: 6 additions & 2 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ protected static function extract($key)
);
}

$prefix = \count($parts) === 3 ? array_shift($parts) : 'JHtml';
$prefix = \count($parts) === 3 ? array_shift($parts) : 'Joomla\\CMS\\HTML\\HTMLHelper';
$file = \count($parts) === 2 ? array_shift($parts) : '';
$func = array_shift($parts);

if (strtolower($prefix) === 'jhtml') {
$prefix = 'Joomla\\CMS\\HTML\\HTMLHelper';
}

return [strtolower($prefix . '.' . $file . '.' . $func), $prefix, $file, $func];
}

Expand Down Expand Up @@ -132,7 +136,7 @@ final public static function _(string $key, ...$methodArgs)
* Support fetching services from the registry if a custom class prefix was not given (a three segment key),
* the service comes from a class other than this one, and a service has been registered for the file.
*/
if ($prefix === 'JHtml' && $file !== '' && static::getServiceRegistry()->hasService($file)) {
if ($prefix === 'Joomla\\CMS\\HTML\\HTMLHelper' && $file !== '' && static::getServiceRegistry()->hasService($file)) {
$service = static::getServiceRegistry()->getService($file);

$toCall = [$service, $func];
Expand Down
20 changes: 17 additions & 3 deletions libraries/src/Table/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use Joomla\Event\DispatcherInterface;
use Joomla\String\StringHelper;

use function ucfirst;

// phpcs:disable PSR1.Files.SideEffects
\defined('JPATH_PLATFORM') or die;
// phpcs:enable PSR1.Files.SideEffects
Expand Down Expand Up @@ -278,21 +280,33 @@ public static function getInstance($type, $prefix = 'JTable', $config = [])
{
// Sanitize and prepare the table class name.
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
$tableClass = $prefix . ucfirst($type);

$tableClass = $prefix . ucfirst($type);
$tableClassLegacy = $tableClass;

if ($prefix === 'JTable') {
$tableClass = 'Joomla\\CMS\\Table\\' . ucfirst($type);
}

// Only try to load the class if it doesn't already exist.
if (!class_exists($tableClass)) {
if (!class_exists($tableClass) && !class_exists($tableClassLegacy)) {
// Search for the class file in the JTable include paths.
$paths = self::addIncludePath();
$pathIndex = 0;

while (!class_exists($tableClass) && $pathIndex < \count($paths)) {
while (!class_exists($tableClass) && !class_exists($tableClassLegacy) && $pathIndex < \count($paths)) {
if ($tryThis = Path::find($paths[$pathIndex++], strtolower($type) . '.php')) {
// Import the class file.
include_once $tryThis;
}
}

if (class_exists($tableClass)) {
$tableClassLegacy = $tableClass;
} elseif (class_exists($tableClass)) {
$tableClass = $tableClassLegacy;
}

if (!class_exists($tableClass)) {
/*
* If unable to find the class file in the Table include paths. Return false.
Expand Down
39 changes: 39 additions & 0 deletions plugins/system/compat/compat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" group="system" method="upgrade">
<name>plg_system_combat</name>
<author>Joomla! Project</author>
<creationDate>2023-03</creationDate>
<copyright>(C) 2023 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>5.0.0</version>
<description>PLG_COMPAT_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\System\Compat</namespace>
<files>
<folder plugin="cache">services</folder>
<folder>src</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_system_compat.ini</language>
<language tag="en-GB">language/en-GB/plg_system_compat.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="classes_aliases"
type="radio"
layout="joomla.form.field.radio.switcher"
label="PLG_COMPAT_FIELD_CLASSES_ALIASES_LABEL"
description="PLG_COMPAT_FIELD_CLASSES_ALIASES_DESCRIPTION"
default="1"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>
49 changes: 49 additions & 0 deletions plugins/system/compat/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @package Joomla.Plugin
* @subpackage System.combat
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Profiler\Profiler;
use Joomla\CMS\Router\SiteRouter;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\System\Compat\Extension\Compat;

return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 5.0.0
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = PluginHelper::getPlugin('system', 'compat');
$dispatcher = $container->get(DispatcherInterface::class);
$profiler = (defined('JDEBUG') && JDEBUG) ? Profiler::getInstance('Application') : null;
$router = $container->has(SiteRouter::class) ? $container->get(SiteRouter::class) : null;

$plugin = new Compat($dispatcher, (array) $plugin, $profiler, $router);
$plugin->setApplication(Factory::getApplication());

return $plugin;
}
);
}
};
Loading