{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/12888","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12888/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12888/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12888/events","html_url":"https://github.com/joomla/joomla-cms/issues/12888","id":189105438,"number":12888,"title":"mod_custom layout is run twice","user":{"login":"aaron-harding","id":897997,"avatar_url":"https://avatars.githubusercontent.com/u/897997?v=3","gravatar_id":"","url":"https://api.github.com/users/aaron-harding","html_url":"https://github.com/aaron-harding","followers_url":"https://api.github.com/users/aaron-harding/followers","following_url":"https://api.github.com/users/aaron-harding/following{/other_user}","gists_url":"https://api.github.com/users/aaron-harding/gists{/gist_id}","starred_url":"https://api.github.com/users/aaron-harding/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaron-harding/subscriptions","organizations_url":"https://api.github.com/users/aaron-harding/orgs","repos_url":"https://api.github.com/users/aaron-harding/repos","events_url":"https://api.github.com/users/aaron-harding/events{/privacy}","received_events_url":"https://api.github.com/users/aaron-harding/received_events","type":"User","site_admin":false},"labels":[{"id":138443932,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/No%20Code%20Attached%20Yet","name":"No Code Attached Yet","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-11-14T12:54:17Z","updated_at":"2016-11-14T14:41:21Z","closed_at":null,"body":"### Steps to reproduce the issue\r\n\r\n1. Create an html override for mod_custom in /templates/**template name**/html/mod_custom/default.php\r\n2. Use following code in the override: \r\n```php\r\n<?php\r\n/**\r\n * @package     Joomla.Site\r\n * @subpackage  mod_custom\r\n *\r\n * @copyright   Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.\r\n * @license     GNU General Public License version 2 or later; see LICENSE.txt\r\n */\r\n\r\ndefined('_JEXEC') or die; ?>\r\n\r\n<div class=\"test-wrapper\">\r\n    <?php echo $module->content; ?>\r\n</div>\r\n```\r\n3. Create a custom module, give it some content in the text editor and then assign to a page.\r\n4. Inspect the page source in the front end of your site.\r\n\r\n### Expected result\r\nExpected to see:\r\n```html\r\n<div class=\"test-wrapper\">\r\n    Module Content here\r\n</div>\r\n```\r\n\r\n\r\n### Actual result\r\nThe module is wrapped twice in the test-wrapper div like so: \r\n```html\r\n<div class=\"test-wrapper\">\r\n    <div class=\"test-wrapper\">\r\n        Module Content here\r\n    </div>\r\n</div>\r\n```\r\n\r\n### System information (as much as possible)\r\nFresh install of Joomla with Blog content.\r\n\r\n\r\n### Additional comments\r\nThis issue only happens with mod_custom. I suspect it has something to do with outputting `$module->content` in the layout which is perhaps run twice by `JModuleHelper::renderModule`?\r\n\r\nThis issue happens even without an override on the module. The original default.php will output:\r\n```html\r\n<div class=\"custom\">\r\n    <div class=\"custom\">\r\n        Module Content here\r\n    </div>\r\n</div>\r\n```"},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/260351958","html_url":"https://github.com/joomla/joomla-cms/issues/12888#issuecomment-260351958","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12888","id":260351958,"user":{"login":"mbabker","id":368545,"avatar_url":"https://avatars.githubusercontent.com/u/368545?v=3","gravatar_id":"","url":"https://api.github.com/users/mbabker","html_url":"https://github.com/mbabker","followers_url":"https://api.github.com/users/mbabker/followers","following_url":"https://api.github.com/users/mbabker/following{/other_user}","gists_url":"https://api.github.com/users/mbabker/gists{/gist_id}","starred_url":"https://api.github.com/users/mbabker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbabker/subscriptions","organizations_url":"https://api.github.com/users/mbabker/orgs","repos_url":"https://api.github.com/users/mbabker/repos","events_url":"https://api.github.com/users/mbabker/events{/privacy}","received_events_url":"https://api.github.com/users/mbabker/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T14:41:21Z","updated_at":"2016-11-14T14:41:21Z","body":"> I would have thought that expected behaviour is to be rendered once and then reused output for the other two modules?\r\n\r\nJoomla doesn't hold in memory the results of rendering a module.  The `$module` object that method is processing is a plain PHP `stdClass` object, it doesn't correspond directly to the database record (because the API also could conceivably support rendering a module without needing any data from the database).  So if what you're saying is true in that the same module's contents are being echoed out multiple times, it would seem to me whatever is feeding the data object into `JModuleHelper::renderModule()` is incorrectly building/structuring that data, not necessarily a bug in that method (since also if you look in that method, at no point does it prepend/append the content but rather sets it and overwrites anything that might already be assigned to the content key of the object).\r\n\r\nWhat could possibly be causing an issue (with all modules in general) is an issue of scope creep.  When a module is rendered, the module's base file includes [these variables](https://github.com/BabDev/Tweet-Display-Back/blob/master/mod_tweetdisplayback.php#L14-L27) defined in `JModuleHelper::renderModule()`.  Since `$module->content` is the result of whatever the module echoes out plus whatever is assigned to the `$content` variable, if a module is actually setting that variable in some form it would result in unexpected output changes."}}
{"actor":{"display_login":"mbabker"}}