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

Custom plugin name can't started with plg_ #38254

Closed
ZhukDmitry opened this issue Jul 11, 2022 · 10 comments
Closed

Custom plugin name can't started with plg_ #38254

ZhukDmitry opened this issue Jul 11, 2022 · 10 comments

Comments

@ZhukDmitry
Copy link

ZhukDmitry commented Jul 11, 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

@ZhukDmitry ZhukDmitry changed the title Custom plugin name can't contain _ symbol Custom plugin name can't started with plg_ Jul 12, 2022
@chmst
Copy link
Contributor

chmst commented Jul 13, 2022

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

@GHSVS-de
Copy link
Contributor

GHSVS-de commented Jul 13, 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

@chmst
Copy link
Contributor

chmst commented Jul 13, 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.

@ChristineWk
Copy link

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.

@ZhukDmitry
Copy link
Author

ZhukDmitry commented Jul 14, 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";
}

}

@ZhukDmitry
Copy link
Author

ZhukDmitry commented Jul 14, 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

@ZhukDmitry
Copy link
Author

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)

@brianteeman
Copy link
Contributor

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

@GHSVS-de
Copy link
Contributor

GHSVS-de commented Jul 14, 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??

@richard67
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants