?
Referenced as Pull Request for: # 6045
avatar islavi
islavi
9 Feb 2015

Steps to reproduce the issue

In libraries\joomla\cache\controller\callback.php
The function "get" in line 148 contains:
$coptions['headerbefore'] = $document->getHeadData();

There are cases when using cache in the module:
$list = JModuleHelper::moduleCache($module, $params, $cacheparams);

And calling this module render:
JModuleHelper::renderModule($module);

Expected result

The module should render correctly.

Actual result

Getting: Fatal error: Call to undefined method JDocumentRaw::getHeadData() in C:\xampp\htdocs\xxxx\libraries\joomla\cache\controller\callback.php on line 148

System information (as much as possible)

Joomla 3.3.6

Additional comments

Can be solved by using:
if (method_exists($document, 'getHeadData')){
$coptions['headerbefore'] = $document->getHeadData();

}

avatar islavi islavi - open - 9 Feb 2015
avatar Bakual
Bakual - comment - 9 Feb 2015

The raw document type doesn't support headers, thus the missing method.

What I wonder is how you end up calling a module in the document type "raw" (JDocumentRaw). That sounds more like a bug in the extension to me. JDocumentRaw certainly isn't meant to produce HTML pages (containing modules and all).

You suggested code likely would work in that it doesn't create a fatal error anymore. However I don't think it's the best idea as it looks more like a workaround for messy coding in another place.

avatar islavi
islavi - comment - 10 Feb 2015

Thanks for your reply.

I'm using AJAX call to refresh a module.
In javascript I use the following:

function moduleRefreshSendAjax (moduleName, moduleId, modulePosition, num){
var data = {
"option": "com_ajax",
"module": moduleName,
"method": "refresh",
"moduleid": moduleId,
"position": modulePosition,
"format": "raw"
};

    jQuery.ajax({
        type: "POST",
        data: data,
        success: function (res) {
            jQuery('.news-' + moduleId).html(res);
        },
        error: function (res) {
            console.log("ERROR: " + res.responseText);
        }
    });
};

And in the server side I use the following method:
public static function refreshAjax() {

$position = $_POST['position'];
$moduleId = $_POST['moduleid'];
$modules =& JModuleHelper::getModules($position);
foreach ($modules as $module) {
if ($module->id == $moduleId) {
return JModuleHelper::renderModule($module);
}
}
}

Is there other good solution to return module HTML from ajax call?

Thanks in advanced


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6028.
avatar Bakual
Bakual - comment - 10 Feb 2015

Ah I see. hat should be a valid usecase indeed. Can you make a PR with your suggested changes?

If you never did a Pull Request before, you can have a look at this doc: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

avatar brianteeman brianteeman - change - 11 Feb 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 12 Feb 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-02-12 21:18:43
Closed_By zero-24
avatar joomla-cms-bot joomla-cms-bot - close - 12 Feb 2015
avatar zero-24
zero-24 - comment - 12 Feb 2015

Closing here as we have a Pull Request by @islavi here: #6045 Thanks!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6028.
avatar joomla-cms-bot
joomla-cms-bot - comment - 12 Feb 2015

Set to "closed" on behalf of @zero-24 by The JTracker Application at issues.joomla.org/joomla-cms/6028

avatar joomla-cms-bot joomla-cms-bot - change - 12 Feb 2015
Closed_Date 2015-02-12 21:18:43 2015-02-12 21:18:49

Add a Comment

Login with GitHub to post a comment