How to query for plugin params from a CLI script? It doesn't work for unpublic plugins.

75 views
Skip to first unread message

Clubnite

unread,
Oct 19, 2016, 12:05:04 PM10/19/16
to Joomla! CMS Development
I dunno whether this is a bug or desired behavior. I am working to build a CLI script to be run via cron job. This script belongs to a plugin and depends on that plugin's params. The plugin itself has restricted access to a non-public group.

Trying to load the related plugin's params via JPluginHelper::getParams('group','plugin') gives me an empty array. I found that the reason lies within JPluginHelper::load() where the database query is built. The query involves an access level check which is correct for normal use cases. I disabled that line testwise which makes the script work and find the plugin. I wonder whether it hasn't been considered to query for plugin parameters from within a commandline script. The executable is supposedly the server and no special Joomla user belonging to a specific Joomla user group.

Mabe I'm on the wrong way. Please tell me if this is a bug or how to correctly implement what I'd like to achive.

Cheers,

Tino

Clubnite

unread,
Oct 21, 2016, 1:36:25 PM10/21/16
to Joomla! CMS Development
Nobody?

Bakual

unread,
Oct 22, 2016, 8:27:28 AM10/22/16
to Joomla! CMS Development
If it is not publich and an access check involved, you need to authenticate an user even from CLI. There is no way around that.

Roberto Segura

unread,
Oct 22, 2016, 9:53:17 AM10/22/16
to joomla-...@googlegroups.com
Why don't you directly retrieve the params with a SQL query and load them into a Registry object?

Roberto Segura
Twitter: @phproberto - Skype: phproberto - Phone: (+34) 636 420 530
http://phproberto.com


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cms+unsubscribe@googlegroups.com.
To post to this group, send email to joomla-dev-cms@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-cms.
For more options, visit https://groups.google.com/d/optout.

Clubnite

unread,
Oct 22, 2016, 4:00:49 PM10/22/16
to Joomla! CMS Development
@Bakual I'm afraid I don't understand you. There is no user that should nor can be authenticated since the script is executed by a CRON job. If you got more details how to do it correctly I'd appreciate to know.

@Roberto actually I'm intended to use the tools provided as usual. Fetching a plugin's params actually is JPluinHelpers' job. Why would I want to bypass that helper when I am able to load a component's params via JComponentHelper in the same place at the same time without any issues and ACL check? Since that works fine I suppose the implementation of JPluinHelper is not correct in this case. Like I said, there is no authenticatable user at runtime, because a CRON job executes the script. But mabe I'm lacking knowledge in this case which is why I asked for a working example.

Michael Babker

unread,
Oct 22, 2016, 4:19:34 PM10/22/16
to joomla-...@googlegroups.com
JPluginHelper also loads the plugins into the event dispatcher, which is why its database query to load data into memory uses the ACL system.  Components don't have a similar concept of ACL at that level hence the reason it doesn't have a filter.  So if you need to bypass the ACL checks, a direct query is more than suitable.  The other option is to start a null session (since JFactory::getUser() uses that for the active user for the request/process) and store a JUser object within it holding a super user's account.

On Sat, Oct 22, 2016 at 3:00 PM, 'Clubnite' via Joomla! CMS Development <joomla-...@googlegroups.com> wrote:
@Bakual I'm afraid I don't understand you. There is no user that should nor can be authenticated since the script is executed by a CRON job. If you got more details how to do it correctly I'd appreciate to know.

@Roberto actually I'm intended to use the tools provided as usual. Fetching a plugin's params actually is JPluinHelpers' job. Why would I want to bypass that helper when I am able to load a component's params via JComponentHelper in the same place at the same time without any issues and ACL check? Since that works fine I suppose the implementation of JPluinHelper is not correct in this case. Like I said, there is no authenticatable user at runtime, because a CRON job executes the script. But mabe I'm lacking knowledge in this case which is why I asked for a working example.
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cms+unsubscribe@googlegroups.com.
To post to this group, send an email to joomla-dev-cms@googlegroups.com.

Clubnite

unread,
Oct 22, 2016, 6:21:06 PM10/22/16
to Joomla! CMS Development
Thanks for the explanation, Michael. I think I'll go the direct database query way then because starting a null-session, looking up the database for the super user id and loading the super user for the sake of passing the plugin's ACL check just to fetch a single plugin parameter appears to be kinda overhead for what I require. Thanks to all responders!
Reply all
Reply to author
Forward
0 new messages