-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Plugin Id is not available to Plugin in CMSPlugin.php #38094
Comments
What would you use the ID for? |
To change the value(s) of a plugin, in particular the params, via my code. As it stands at the moment I have to do another call to the DB to determine the In the sample of code pasted below that I am using at the moment, the first three lines would not be required if the id was available in the same way the other three values were set in the __construct.
|
$plugin = PluginHelper::getPlugin($type, $name);
echo $plugin->id; should do |
So the issue is not how to get the plugin id but for consistency and ease of use it should already be available and not require another call to Once
The same should also apply to the new column custom_data in the |
You can safe it in your own class when you need it. Just override the constructor. |
We do not need this in our core plugins and when it is needed like in your case, you can always override plugin constructor to store data for your own usage as pointed out by @laoneo above. Therefore, I'm closing this issue. |
This issue is/was opened to highlight a code quality or consistency concern and is not about asking for assistance on how to get the In It seems a bit like getting four new tyres(tires) for you car and they only put air in three of them and expect you put air in the fourth for no apparent reason other than that you can. If the 'decision' is that In my opinion to close this issue then some lines of code should to be added or other lines of redundant code should be removed. For ease of use, less code code and a potentially repetitive call to the DB for a value already retrieved then making the extension_id available by default should be reconsidered. If you disagree then leave this issue closed. |
Yes. Look like extension_id is not used here and could be removed. However, we could not remove it now (at least until Joomla 6) because it would cause backward incompatible changes (in case some third party plugins like yours use it) We also could not add _id property now as you suggested because:
So I will still keep the issue closed for now. If you still disagree, I will ask maintainers for final decision :). |
@joomdonation , I don't really see the relevance that because the 'core' doesn't use it then it isn't a worthwhile thing to make available to the extension developer, I am sure there are plenty of functions and features available to developers that the core doesn't use. If there was a potential collision with someone's own plugins use of There is also the more recent inclusion of the It looks to me that whenever the four fields were added to |
While in the execution of a plugin the id of the plugin in #__extensions is not available.
The
id
is retrieved as part of PluginHelper.php and passed as part of$config
to the__construct
of CMSPlugin along with three other values,type
,name
andparams
and are assigned to$this->_type
,$this->_name
and$this-params
respectively howeverid
is not assigned to$this->_id
as you might expect.Steps to reproduce the issue
$fred = $this->_id
Expected result
$fred = 1
Actual result
$this->_id not found
System information (as much as possible)
If this code was added to the __construct of CMSPlugin.php at around line #114 then the problem would be resolved.
Additional comments
The text was updated successfully, but these errors were encountered: