Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4] Add Joomla 5 compat plugin to 4.4.0 to fix class "JPlugin" not found error on update to 5 #2995

Closed
jgerman-bot opened this issue Sep 14, 2023 · 0 comments · Fixed by #3002

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#41738 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_admin/sql/updates/mysql/4.4.0-2023-09-13.sql b/administrator/components/com_admin/sql/updates/mysql/4.4.0-2023-09-13.sql
new file mode 100644
index 0000000000000..5d50eea48ef18
--- /dev/null
+++ b/administrator/components/com_admin/sql/updates/mysql/4.4.0-2023-09-13.sql
@@ -0,0 +1,2 @@
+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_behaviour_compat', 'plugin', 'compat', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', -1, 0);
diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.4.0-2023-09-13.sql b/administrator/components/com_admin/sql/updates/postgresql/4.4.0-2023-09-13.sql
new file mode 100644
index 0000000000000..775af7b681f31
--- /dev/null
+++ b/administrator/components/com_admin/sql/updates/postgresql/4.4.0-2023-09-13.sql
@@ -0,0 +1,2 @@
+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_behaviour_compat', 'plugin', 'compat', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', -1, 0);
diff --git a/administrator/language/en-GB/plg_behaviour_compat.ini b/administrator/language/en-GB/plg_behaviour_compat.ini
new file mode 100644
index 0000000000000..747bdd32d5087
--- /dev/null
+++ b/administrator/language/en-GB/plg_behaviour_compat.ini
@@ -0,0 +1,7 @@
+; Joomla! Project
+; (C) 2023 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_BEHAVIOUR_COMPAT="Behaviour - Backward Compatibility"
+PLG_COMPAT_XML_DESCRIPTION="This plugin should be enabled before updating to Joomla 5."
diff --git a/administrator/language/en-GB/plg_behaviour_compat.sys.ini b/administrator/language/en-GB/plg_behaviour_compat.sys.ini
new file mode 100644
index 0000000000000..747bdd32d5087
--- /dev/null
+++ b/administrator/language/en-GB/plg_behaviour_compat.sys.ini
@@ -0,0 +1,7 @@
+; Joomla! Project
+; (C) 2023 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_BEHAVIOUR_COMPAT="Behaviour - Backward Compatibility"
+PLG_COMPAT_XML_DESCRIPTION="This plugin should be enabled before updating to Joomla 5."
diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql
index 1274f65019df8..edc4f6bcd967a 100644
--- a/installation/sql/mysql/base.sql
+++ b/installation/sql/mysql/base.sql
@@ -258,8 +258,9 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
 (0, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, 1, '', '', '', 1, 0),
 (0, 'plg_authentication_joomla', 'plugin', 'joomla', 'authentication', 0, 1, 1, 1, 1, '', '', '', 2, 0),
 (0, 'plg_authentication_ldap', 'plugin', 'ldap', 'authentication', 0, 0, 1, 0, 1, '', '{"host":"","port":"389","use_ldapV3":"0","negotiate_tls":"0","no_referrals":"0","auth_method":"bind","base_dn":"","search_string":"","users_dn":"","username":"admin","password":"bobby7","ldap_fullname":"fullName","ldap_email":"mail","ldap_uid":"uid"}', '', 3, 0),
-(0, 'plg_behaviour_taggable', 'plugin', 'taggable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
-(0, 'plg_behaviour_versionable', 'plugin', 'versionable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
+(0, 'plg_behaviour_compat', 'plugin', 'compat', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
+(0, 'plg_behaviour_taggable', 'plugin', 'taggable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
+(0, 'plg_behaviour_versionable', 'plugin', 'versionable', 'behaviour', 0, 1, 1, 1, 1, '', '{}', '', 3, 0),
 (0, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 0, 1, 0, 1, '', '{"public_key":"","private_key":"","theme":"clean"}', '', 1, 0),
 (0, 'plg_captcha_recaptcha_invisible', 'plugin', 'recaptcha_invisible', 'captcha', 0, 0, 1, 0, 1, '', '{"public_key":"","private_key":"","theme":"clean"}', '', 2, 0),
 (0, 'plg_content_confirmconsent', 'plugin', 'confirmconsent', 'content', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql
index b081088994320..84bdd9e9b1c3e 100644
--- a/installation/sql/postgresql/base.sql
+++ b/installation/sql/postgresql/base.sql
@@ -264,8 +264,9 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
 (0, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, 1, '', '', '', 1, 0),
 (0, 'plg_authentication_joomla', 'plugin', 'joomla', 'authentication', 0, 1, 1, 1, 1, '', '', '', 2, 0),
 (0, 'plg_authentication_ldap', 'plugin', 'ldap', 'authentication', 0, 0, 1, 0, 1, '', '{"host":"","port":"389","use_ldapV3":"0","negotiate_tls":"0","no_referrals":"0","auth_method":"bind","base_dn":"","search_string":"","users_dn":"","username":"admin","password":"bobby7","ldap_fullname":"fullName","ldap_email":"mail","ldap_uid":"uid"}', '', 3, 0),
-(0, 'plg_behaviour_taggable', 'plugin', 'taggable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
-(0, 'plg_behaviour_versionable', 'plugin', 'versionable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
+(0, 'plg_behaviour_compat', 'plugin', 'compat', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 1, 0),
+(0, 'plg_behaviour_taggable', 'plugin', 'taggable', 'behaviour', 0, 1, 1, 0, 1, '', '{}', '', 2, 0),
+(0, 'plg_behaviour_versionable', 'plugin', 'versionable', 'behaviour', 0, 1, 1, 1, 1, '', '{}', '', 3, 0),
 (0, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 0, 1, 0, 1, '', '{"public_key":"","private_key":"","theme":"clean"}', '', 1, 0),
 (0, 'plg_captcha_recaptcha_invisible', 'plugin', 'recaptcha_invisible', 'captcha', 0, 0, 1, 0, 1, '', '{"public_key":"","private_key":"","theme":"clean"}', '', 2, 0),
 (0, 'plg_content_confirmconsent', 'plugin', 'confirmconsent', 'content', 0, 0, 1, 0, 1, '', '{}', '', 1, 0),
diff --git a/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php
index 167ef57a3142f..9b236c1a8e798 100644
--- a/libraries/src/Extension/ExtensionHelper.php
+++ b/libraries/src/Extension/ExtensionHelper.php
@@ -172,6 +172,7 @@ class ExtensionHelper
         ['plugin', 'ldap', 'authentication', 0],
 
         // Core plugin extensions - behaviour
+        ['plugin', 'compat', 'behaviour', 0],
         ['plugin', 'taggable', 'behaviour', 0],
         ['plugin', 'versionable', 'behaviour', 0],
 
diff --git a/plugins/behaviour/compat/compat.xml b/plugins/behaviour/compat/compat.xml
new file mode 100644
index 0000000000000..bdae5a303c883
--- /dev/null
+++ b/plugins/behaviour/compat/compat.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<extension type="plugin" group="behaviour" method="upgrade">
+	<name>plg_behaviour_compat</name>
+	<author>Joomla! Project</author>
+	<creationDate>2023-09</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>4.4.0</version>
+	<description>PLG_COMPAT_XML_DESCRIPTION</description>
+	<namespace path="src">Joomla\Plugin\Behaviour\Compat</namespace>
+	<files>
+		<folder plugin="compat">services</folder>
+		<folder>src</folder>
+	</files>
+	<languages>
+		<language tag="en-GB">language/en-GB/plg_behaviour_compat.ini</language>
+		<language tag="en-GB">language/en-GB/plg_behaviour_compat.sys.ini</language>
+	</languages>
+</extension>
diff --git a/plugins/behaviour/compat/services/provider.php b/plugins/behaviour/compat/services/provider.php
new file mode 100644
index 0000000000000..37e578701e266
--- /dev/null
+++ b/plugins/behaviour/compat/services/provider.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @package     Joomla.Plugin
+ * @subpackage  Behaviour.compat
+ *
+ * @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\DI\Container;
+use Joomla\DI\ServiceProviderInterface;
+use Joomla\Event\DispatcherInterface;
+use Joomla\Plugin\Behaviour\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   __DEPLOY_VERSION__
+     */
+    public function register(Container $container)
+    {
+        $container->set(
+            PluginInterface::class,
+            function (Container $container) {
+                $plugin     = PluginHelper::getPlugin('behaviour', 'compat');
+                $dispatcher = $container->get(DispatcherInterface::class);
+
+                $plugin = new Compat($dispatcher, (array) $plugin);
+                $plugin->setApplication(Factory::getApplication());
+
+                return $plugin;
+            }
+        );
+    }
+};
diff --git a/plugins/behaviour/compat/src/Extension/Compat.php b/plugins/behaviour/compat/src/Extension/Compat.php
new file mode 100644
index 0000000000000..5beb39b830ff4
--- /dev/null
+++ b/plugins/behaviour/compat/src/Extension/Compat.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * @package     Joomla.Plugin
+ * @subpackage  Behaviour.compat
+ *
+ * @copyright   (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
+ * @license     GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+namespace Joomla\Plugin\Behaviour\Compat\Extension;
+
+use Joomla\CMS\Plugin\CMSPlugin;
+use Joomla\Event\SubscriberInterface;
+
+// phpcs:disable PSR1.Files.SideEffects
+\defined('_JEXEC') or die;
+// phpcs:enable PSR1.Files.SideEffects
+
+/**
+ * Joomla! Compat Plugin.
+ *
+ * @since  __DEPLOY_VERSION__
+ */
+final class Compat extends CMSPlugin implements SubscriberInterface
+{
+    /**
+     * Returns an array of CMS events this plugin will listen to and the respective handlers.
+     *
+     * @return  array
+     *
+     * @since  __DEPLOY_VERSION__
+     */
+    public static function getSubscribedEvents(): array
+    {
+        /**
+         * This plugin does not listen to any events.
+         */
+        return [];
+    }
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants