?
avatar jschmi01
jschmi01
30 Jan 2015

Steps to reproduce the issue

change modules's menu asssignment from "all" to "only selected" (even if all menuitems are checked).

Expected result

should work the same way as with menu asssignment to "all" menu-items

Actual result

call of ajax.php "$moduleObject = JModuleHelper::getModule('mod_' . $module, null);" returns Module id="0" (means module has not been found) and casts error404 with meessage:
LogicException: Module _ mod_modname is not published, you do not have access to it, or it's not assigned to the current menu item"_

System information (as much as possible)

Additional comments

checking module's authority, enablement or menu-assignment with JModuleHelper::getModule will not work and is not the correct way for module checking via ajax-interface. It should be done in other ways (e.g. like requiring a module-id in ajax-request additionally to the module-name an then do checking with modules table and module-menu-table)
Note that if no check is done at all - request will fail anyway later, if access to module is restricted or module is not published.

avatar jschmi01 jschmi01 - open - 30 Jan 2015
avatar jschmi01 jschmi01 - change - 30 Jan 2015
The description was changed
avatar jschmi01 jschmi01 - change - 30 Jan 2015
The description was changed
avatar Bakual
Bakual - comment - 30 Jan 2015

Did you try passing an Itemid to the AJAX request URL?
@betweenbrain can you look into that?

avatar jschmi01 jschmi01 - change - 30 Jan 2015
The description was changed
avatar jschmi01
jschmi01 - comment - 30 Jan 2015

What do you mean with Itemid (do you mean menu-itemid?) - this is not documented at all - where would the module developer get the Itemid from?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5930.
avatar Bakual
Bakual - comment - 30 Jan 2015

In Joomla, any URL request should contain an Itemid (the menu item). Otherwise you get unexpected results like what you described.

Usually. JRoute::_() takes care of that by using the active Itemid if none is specified. In case of your AJAX URL, you probably don't use SEF URLs (because they don't make sense there), and thus don't use JRoute::_(). So you have to add the active Itemid yourself to the request.

avatar jschmi01
jschmi01 - comment - 30 Jan 2015

checked this - and this fixed it (added code to my module to provide "Itemid" of active menu). Nevertheless this has not been documented with com_ajax but should as this is very important for developers.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5930.
avatar Fedik
Fedik - comment - 30 Jan 2015

I think com_ajax must work without itemid, as it do not pass any parameters to the module helper,
so I would count it as :bug:

avatar brianteeman
brianteeman - comment - 30 Jan 2015

The docs.joomla.org web site is open for anyone to add/edit documentation -
it would be really helpful for others if you would add your findings and
advice to the docs

On 30 January 2015 at 10:36, Fedir Zinchuk notifications@github.com wrote:

I think com_ajax must work without itemid, as it do not pass any
parameters to the module helper


Reply to this email directly or view it on GitHub
#5930 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar Fedik
Fedik - comment - 30 Jan 2015

In the past was suggestion do check "whether module available" independant from Itemid https://github.com/joomla/joomla-cms/pull/3071/files#diff-4de1edbd5685ce87aa27e65ebca2b92bR89

avatar Bakual
Bakual - comment - 30 Jan 2015

I think com_ajax must work without itemid, as it do not pass any parameters to the module helper

com_ajax itself works fine without Itemid, as long as you don't make any requests which need one :smile:
Accessing a module is one of those cases where Joomla needs an Itemid to see if the module is available.
Imagine if you didn't make that check, then everyone could access the AJAX method even if the module is restricted to a specific usergroup or disabled. That opens the door for quite a few possible security issues.

Nevertheless this has not been documented with com_ajax but should as this is very important for developers.

It's not specific to com_ajax. It's a general rule that every request to Joomla has to contain an Itemid. Either explicit (by adding &Itemid=123) or implicit (using a SEF URL with a menu alias). No exceptions.

avatar jschmi01 jschmi01 - close - 30 Jan 2015
avatar zero-24 zero-24 - close - 30 Jan 2015
avatar jschmi01 jschmi01 - close - 30 Jan 2015
avatar jschmi01 jschmi01 - change - 30 Jan 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-01-30 11:33:30
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment