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

Loadmodule plugin refuses to load copied modules #11065

Merged
merged 1 commit into from
Jul 16, 2016

Conversation

demis-palma
Copy link
Contributor

@demis-palma demis-palma commented Jul 10, 2016

Testing Instructions

  1. In the back-end, create a module for the front-end side. The module type doesn't matter. Give it a name, for example "My Module".
  2. Duplicate it with the "Duplicate" button in the top toolbar. The new module is automatically named "My Module (2)". Leave its name as is.
  3. On both modules, ensure that the "Position" is "unset", or set it to a non-existing template position: we want to load the module through the content-loadmodule plugin, not through a standard template position. In addition ensure that the "Status" is "Published", and "Menu Assignment" to "All pages". These conditions are necessary for the content-loadmodule to load the module.
  4. Create an article. Within its content load the module using the content-loadmodule plugin. To avoid struggling with the correct syntax, you can use the "Module" editor button introduced recently. There select "My Module (2)" from the list by the green button, which corresponds to {loadmodule}. Do not use the yellow button, which would correspond to {loadposition}.
  5. Take a look to your module in the front-end. I created a Menu Item of type "Articles » Single Article" for that purpose, but browsing your article through a blog view should make no difference.
  6. You should see that the plugin code has not been replaced with the actual module. The plugin seems not working at all.

Summary of Changes

The problem is that loadmodule calls preg_replace using a literal string as pattern, while in a regular expression the parenthesis are metacharacters and must be escaped.

Frankly, I would suggest to change preg_replace with str_replace, but I've just escaped the parenthesis to fix this bug without opening a debate.

@demis-palma demis-palma changed the title Fixed Loadmodule parenthesis in title Loadmodule plugin refuses to load copied modules Jul 10, 2016
@chrisdavenport
Copy link
Contributor

Well spotted. Regular expressions can be rather slow so I agree that str_replace would be preferable.

@RonakParmar
Copy link

I have follow above steps and not able to re-produce this issue in latest staging branch.
Joomla! Version: Joomla! 3.6.0-rc Release Candidate [ Noether ] 28-June-2016 20:34 GMT

With PR and without PR the module is being loaded fine in my article at front end site.


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

@killoltailored
Copy link

I have follow your testing instructions but not able to reproduce this issue in latest version of Joomla with applied patch and without applying patch.

Joomla! Version : Joomla! 3.6.0-rc Release Candidate [ Noether ] 28-June-2016 20:34 GMT


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

@RonakParmar
Copy link

I have used code to load the module in article which was "{loadmodule mod_articles_archive}".
I have noticed that it was loading original module not the copied module both module name were same in database "mod_articles_archive" so, not able to load copied module. If we used title of module then it was not replaced at front site, it was simple test for article.


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

@RonakParmar
Copy link

I have tested this item ✅ successfully on bda657a

After using the "Module" button it works fine.


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

@killoltailored
Copy link

I have tested this item ✅ successfully on bda657a

I have tested successfully
After use of "Module" button


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

@gunjanpatel
Copy link
Contributor

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 11, 2016
@brianteeman brianteeman added this to the Joomla 3.6.1 milestone Jul 11, 2016
@roland-d roland-d merged commit 851cf18 into joomla:staging Jul 16, 2016
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 16, 2016
@demis-palma demis-palma deleted the module-title branch July 29, 2016 21:41
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

8 participants