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

When preparing module content, pass the params #23573

Closed
wants to merge 2 commits into from

Conversation

okonomiyaki3000
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

When using the 'Prepare Content' option in mod_custom, the module params will be passed to the event handler. The 'onContentPrepare' event accepts a params (Registry) object but, for most types of content, none is sent. Why? We actually need this.

Unless there is some good reason why params are not being passed here and in a lot of other cases where they could be, I will expand on this to have them passed in all suitable cases. Also, JHtmlContent::prepare does something weird as well. When $params is not passed (or passed as null), it creates $params as a JObject and passes it to the plugins. Which is weird because you'd really want a Registry there. But worst of all is that most callers of that function do not pass null but rather '' so then it's not even set as a JObject, it's just an empty string. So plugins don't know what to expect. It's a mess. I recommend that, when $params is not a Registry, we do $params = new Registry($params); so that we can always pass a registry to the plugins.

Testing Instructions

OK... so to test this I guess you're going to want to create a content plugin that implements onContentPrepare and then set one or more modules to prepare content.

Expected result

I expect a module which prepares content (or any item which prepares content and has params) to pass its params to the content plugins.

Actual result

As it is, modules which prepare content are not passing their params.

Documentation Changes Required

Maybe

@okonomiyaki3000
Copy link
Contributor Author

I've fixed JHtmlContent::prepare so that it consistently passes $params as a Registry to onContentPrepare. It may or may not be an empty Registry but it should be one. The plugins should not have to guess what kind of thing they're receiving. Ideally, Joomla will never pass anything other than Registry there and then plugin functions can be type-hinted.

@viocassel
Copy link
Contributor

I have tested this item ✅ successfully on cfa3adc


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

@HLeithner
Copy link
Member

This is an API change and will likely not go into J3, please rebase your PR against 4.0 branch.

@okonomiyaki3000
Copy link
Contributor Author

@HLeithner I see it as more of a bugfix but OK, I can do that.

@ghost ghost added J3 Issue and removed J3 Issue labels Apr 5, 2019
@ghost ghost removed the J3 Issue label Apr 19, 2019
@ghost
Copy link

ghost commented Apr 24, 2019

closing as Pull Request will be rebased against 4.0-Branch.

@ghost ghost closed this Apr 24, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants