No Code Attached Yet Information Required bug
avatar ZhukDmitry
ZhukDmitry
11 Jul 2022

Steps to reproduce the issue

When you try to create custom plugin with name like "plg_MyPlugin" - it doesn't work in Joomla 4

But if you create plugin plgMyPlugin - it works

Expected result

Plugin name can have name started with plg_

Actual result

System information (as much as possible)

Joomla! Version | 4.1.5
PHP Version | 8.0.18

Additional comments

avatar ZhukDmitry ZhukDmitry - open - 11 Jul 2022
avatar joomla-cms-bot joomla-cms-bot - change - 11 Jul 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Jul 2022
avatar ZhukDmitry ZhukDmitry - change - 12 Jul 2022
Title
Custom plugin name can't contain _ symbol
Custom plugin name can't started with plg_
avatar ZhukDmitry ZhukDmitry - edited - 12 Jul 2022
avatar ZhukDmitry ZhukDmitry - change - 12 Jul 2022
The description was changed
avatar ZhukDmitry ZhukDmitry - edited - 12 Jul 2022
avatar chmst
chmst - comment - 13 Jul 2022

Did that work in J3?
It surely works if you add the plugin group as in all other plugins: plg_content_nameoftheplugin.

avatar chmst chmst - change - 13 Jul 2022
Labels Added: Information Required
avatar chmst chmst - labeled - 13 Jul 2022
avatar GHSVS-de
GHSVS-de - comment - 13 Jul 2022

Can't confirm this issue. I created a test plugin here: https://github.com/GHSVS-de/plg_mybaseplugin

As long as the mandatory attributes type and group are configured correctly in the mandatory manifest XML the name of the plugin can be whatever you want.

See https://github.com/GHSVS-de/plg_mybaseplugin/blob/main/mybaseplugin.xml#L2-L3

You can also use a custom group (= folder in /plugins/) if you want.

The demo plugin can be installed, activated, opened, saved and uninstalled without any issues:
https://github.com/GHSVS-de/plg_mybaseplugin/raw/main/plg_mybaseplugin.zip

avatar chmst
chmst - comment - 13 Jul 2022

Same here, also checked with capital letters. So please @ZhukDmitry specify what exactly does not work - error message? How did you install your plugin? you also can append your manifestfile here.

avatar ChristineWk
ChristineWk - comment - 14 Jul 2022

Difference between : plg_myBasePlugin and plg_MyPlugin
After the underscore = starts with a capital letter = don't know if relevant?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38254.

avatar ZhukDmitry
ZhukDmitry - comment - 14 Jul 2022

It works in J3, I just trying convert to support J4

Here my test plugin
-- manifest

PLG_ZHOSMMAP Sep 2018 Zhuk Dmitry ZhukDL@gmail.com http://zhuk.cc Copyright http://www.gnu.org/licenseses/gpl-2.0.html GNU/GPLv2 or later 3.22.1.11 PLG_ZHOSMMAP_DESCRIPTION plg_zhosmmap.php index.html language helpers
<languages>
            <language tag="en-GB">language/en-GB/en-GB.plg_content_plg_zhosmmap.ini</language>
</languages>
    <!-- UPDATESERVER DEFINITION -->
    <updateservers>
            <!-- Note: No spaces or linebreaks allowed between the server tags -->
            <server type="extension" priority="1" name="Zh OSM Map Plugin Update Site">http://zhuk.cc/update/plg_zhosmmap/extension.xml</server>
    </updateservers>

--- plugin code

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Plugin\CMSPlugin;

class plgContentplg_zhosmmap extends CMSPlugin
{

protected $app;

public function onContentPrepare($context, &$article, &$params, $page = 0)
{

	$article->text = "Hello";
}

}

avatar ZhukDmitry
ZhukDmitry - comment - 14 Jul 2022

My plugin name
filename plugin="plg_zhosmmap"

and plugin class
class plgContentplg_zhosmmap extends CMSPlugin

it is not processed

if I change name and files to any other (for example plgzhosmmap), - it works

avatar ZhukDmitry
ZhukDmitry - comment - 14 Jul 2022

Probably I must to name my plugin without plg_, but I did it like the other extensions like rules for j3 (component = com_, module = mod_, and so on)

avatar brianteeman
brianteeman - comment - 14 Jul 2022

Just look at how all the core plugins are named and structured.

avatar GHSVS-de
GHSVS-de - comment - 14 Jul 2022

I think (don't know for sure) it's this line that is the reason that plugin base file/classes don't work any longer if they start with plg_ or (which is a bit harsh) contain plg_
https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Extension/ExtensionManagerTrait.php#L87

Later in the chain loadPluginFromFilesystem() can't find the plugin base file, better: can't find the class:
https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Extension/ExtensionManagerTrait.php#L192

That's new but expected from my point of view. Maybe the plugin lagacy mode works different??

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023
avatar richard67 richard67 - change - 27 Feb 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-02-27 12:39:01
Closed_By richard67
avatar richard67 richard67 - close - 27 Feb 2023
avatar richard67
richard67 - comment - 27 Feb 2023

Closing as having a pull request. Please test #39954 . Thanks in advance.

Add a Comment

Login with GitHub to post a comment