[BUG]: JComponentHelper Deprecated in J6 #1258

Closed
opened 2025-10-04 18:25:18 +00:00 by mwweb · 2 comments

What Happened?

I have a component that checks if another component is installed. If it is not installed, or is not enabled, then installation does not precede. However, if the component is installed and enabled, then the component will install. This works flawlessly in Joomla 5.

In Joomla 6, upon attempting to install I receive a message Class "JComponentHelper" not found.

In doing some digging, the only way to make JComponnentHelper work in J6 is to enable the Behaviour - Backward Compatibility 6 plugin, and ensure that the Class Aliases toggle is enabled.

I looks as though JComponentHelper is being/has been replaced with ComponentHelper in the J6 API. The below code is from the Joomla 6 classmap.php in the above mentioned compatibility plugin.

Steps to reproduce the Bug

Create a component using JComponentHelper, such as the code below. Attempt to install in Joomla 6.

            // Check if the required component is installed
            $requiredComponent = 'com_demo'; // Replace with the actual component name

            if (!JComponentHelper::isEnabled($requiredComponent, true)) {
                // If the required component is not installed, abort the installation
                JFactory::getApplication()->enqueueMessage('The installation of "Demo2" requires the "Demo" component to be installed and enabled.', 'error');
                return false; // Return false to stop the installation

Which Joomla version are you compiling in?

6.0.0-rc1

Which PHP version are you compiling in?

8.3.25

Which Joomla versions are you targeting?

6.x

Which PHP version are you targeting?

8.3+

Which Web server is JCB running on?

Apache/2.4.65 (Debian)

Which Relational Database is JCB running on?

11.7.2-MariaDB-ubu2404

Which OS is JCB running on?

Ubuntu 24.04.3 LTS

Which JCB version are you using?

6.0.0-rc1

Where in JCB did this issue occur?

Installation of a component

On which browsers did you encounter the issue?

Firefox

Additional Comments

No response

### What Happened? I have a component that checks if another component is installed. If it is not installed, or is not enabled, then installation does not precede. However, if the component is installed and enabled, then the component will install. This works flawlessly in Joomla 5. In Joomla 6, upon attempting to install I receive a message Class "JComponentHelper" not found. In doing some digging, the only way to make JComponnentHelper work in J6 is to enable the Behaviour - Backward Compatibility 6 plugin, and ensure that the Class Aliases toggle is enabled. I looks as though JComponentHelper is being/has been replaced with ComponentHelper in the J6 API. The below code is from the Joomla 6 classmap.php in the above mentioned compatibility plugin. ### Steps to reproduce the Bug Create a component using JComponentHelper, such as the code below. Attempt to install in Joomla 6. ``` // Check if the required component is installed $requiredComponent = 'com_demo'; // Replace with the actual component name if (!JComponentHelper::isEnabled($requiredComponent, true)) { // If the required component is not installed, abort the installation JFactory::getApplication()->enqueueMessage('The installation of "Demo2" requires the "Demo" component to be installed and enabled.', 'error'); return false; // Return false to stop the installation ``` ### Which Joomla version are you compiling in? 6.0.0-rc1 ### Which PHP version are you compiling in? 8.3.25 ### Which Joomla versions are you targeting? 6.x ### Which PHP version are you targeting? 8.3+ ### Which Web server is JCB running on? Apache/2.4.65 (Debian) ### Which Relational Database is JCB running on? 11.7.2-MariaDB-ubu2404 ### Which OS is JCB running on? Ubuntu 24.04.3 LTS ### Which JCB version are you using? 6.0.0-rc1 ### Where in JCB did this issue occur? Installation of a component ### On which browsers did you encounter the issue? Firefox ### Additional Comments _No response_
mwweb added the Bug label 2025-10-04 18:25:18 +00:00
Owner

I don't quite see how this could be considered a bug if the code in question was manually introduced by you.

To correctly use Joomla's native classes in JCB-generated code, we've provided Joomla Powers, which handle this automatically for you. You can achieve the same functionality cleanly like this:

// Check if the required component is installed
$requiredComponent = 'com_demo'; // Replace with the actual component name

if (!Joomla___aeb8e463_291f_4445_9ac4_34b637c12dbd___Power::isEnabled($requiredComponent, true))
{
	// If the required component is not installed, abort the installation
	Joomla___39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->enqueueMessage(
		'The installation of "Demo2" requires the "Demo" component to be installed and enabled.',
		'error'
	);
	return false; // Stop the installation
}

When written this way, JCB will automatically add the correct use statements and manage the class imports as needed.

Using the Joomla Power links is the only reliable and future-proof way to replace legacy class names with the proper namespaced equivalents used in Joomla 4 and beyond.

Therefore, if JComponentHelper fails in Joomla 6, that's fully expected behavior — it's a Joomla core deprecation, not a JCB bug.

I don't quite see how this could be considered a bug if the code in question was manually introduced by you. To correctly use Joomla's native classes in JCB-generated code, we've provided **Joomla Powers**, which handle this automatically for you. You can achieve the same functionality cleanly like this: ```php // Check if the required component is installed $requiredComponent = 'com_demo'; // Replace with the actual component name if (!Joomla___aeb8e463_291f_4445_9ac4_34b637c12dbd___Power::isEnabled($requiredComponent, true)) { // If the required component is not installed, abort the installation Joomla___39403062_84fb_46e0_bac4_0023f766e827___Power::getApplication()->enqueueMessage( 'The installation of "Demo2" requires the "Demo" component to be installed and enabled.', 'error' ); return false; // Stop the installation } ``` When written this way, **JCB will automatically add the correct `use` statements** and manage the class imports as needed. Using the **Joomla Power links** is the only reliable and future-proof way to replace legacy class names with the proper namespaced equivalents used in Joomla 4 and beyond. Therefore, if `JComponentHelper` fails in Joomla 6, that's fully expected behavior — it's a Joomla core deprecation, not a JCB bug.
Owner

Here is the index of Joomla Powers available already:

https://git.vdm.dev/joomla/joomla-powers

remember to replace the --- with ___ in the JPK to activate that Joomla! Power in your code.

You can also add your own beyond this list... in the Joomla Powers area.

Here is the index of Joomla Powers available already: https://git.vdm.dev/joomla/joomla-powers > remember to replace the `---` with` ___` in the JPK to activate that Joomla! Power in your code. You can also add your own beyond this list... in the Joomla Powers area.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1258