Skip to content

Troubleshooting

I cannot save some or any settings, I get a Cannot communicate with server Unexpected token < in JSON error message

As of 2023-02-27, there is a bug in the YooTheme WidgetKit component that breaks 4SEF (and potentially more extensions from us and others) communication with your Joomla site.

Widgetkit 3.1.16 was released near March 17, 2023, and should contain a fix for this issue. Please refer to the YooTheme support forum thread where this is discussed for any further assistance from YooTheme.

That's not a problem in 4SEF and nothing can be done on our side to fix it.

We have identified the problem and multiple users have passed on the information to YooTheme. The YooTheme support forum thread where this is discussed is here.

Until YooTheme comes up with a fixed update, you can:

  • disable widgetkit if you do not actually use it

or

  • apply the following bug fix to WidgetKit:

1 - Open the file /administrator/components/com_widgetkit/vendor/yootheme/framework/src/Routing/Request.php at around line 67, you'll see:

$this->server     = new ServerBag($server ?: $_SERVER);
$this->headers    = new HeaderBag($this->server->getHeaders());

// decode json content type
if (stripos($this->headers->get('CONTENT_TYPE') ?: '', 'application/json') !== false) {
    if ($json = json_decode(@file_get_contents('php://input'), true)) {
        $this->request->add($json);
    }
}

2 - Replace this section so that it looks like this:

$this->server     = new ServerBag($server ?: $_SERVER);
$this->headers    = new HeaderBag($this->server->getHeaders());

// decode json content type
// Fix by Weeblr
if (stripos($this->headers->get('CONTENT_TYPE') ?: '', 'application/json') !== false) {
    if ($json = json_decode(@file_get_contents('php://input'), true)) {
        $saferJson = empty($json) || !is_array($json)
            ? [$json]
            : $json;
        $this->request->add($saferJson);
    }
}
// End fix by Weeblr

3 - After saving the modified file, 4SEF should work normally again

I cannot save some or any settings, I get a Cannot communicate with server Unexpected token < in JSON error message (JoomlaTools)

As of 2023-07-200, websites using any of the JoomlaTools extensions such as Docman or Logman will experience the same issues as described above for WidgetKit.

These extensions include JoomlaTools Koowa framework, usually as a Joomla system plugin. This framework unfortunately and incorrectly intercepts 4SEF communication with your server, but fails with a PHP error in doing so and therefore prevents 4SEF from operating.

JoomlaTools is aware of the problem but no fixed version has been release to our knowledge yet. We invite you to contact JoomlaTools directly to obtain a fixed version, or disable or uninstall these extensions when no other options exist.

Until JoomlaTools releases a fixed version, you can:

  • disable that extension if not actively using it

or

  • apply the following bug fix:

1 - Open the file /libraries/joomlatools/library/dispatcher/request/abstract.php at around line 211, you'll see:

$this->data->add($data);

2 - Replace this section so that it looks like this:

// Weeblr 2023-07-20
//$this->data->add($data);
$saferData = !is_array($data)
    ? [$data]
    : $data;
$this->data->add($saferData);
// Weeblr 2023-07-20

3 - After saving the modified file, 4SEF should work normally again

I cannot save some or any settings

This is caused in most cases by a security system called mod_security running on your server. Depending on mod_security configuration (which changes from one hosting company to the next), requests made by 4SEF to save data to the server may be blocked.

If you run your own server, you can disable mod_security altogether, or study the log files to see wich rules are triggered and adjust them to allow 4SEF to work.

Otherwise, you'll need to talk to your hosting company so that they can do that for you.

Pagination is broken when using a T3-based template

T3 is one of Joomlart template framework and is commonly found on Joomla 3 websites. Due to using a non-standard files layout, they use a technique to force Joomla into loading their file meant to style pagination.

However, 4SEF also has to make Joomla use 4SEF own Pagination class. Depending on your site setup, either Joomlart or 4SEF Pagination override is used but not both resulting in:

  • if 4SEF override is used, pagination works but is not styled properly
  • if Joomla override is used, pagination just does not work at all
Why must 4SEF force its own Pagination class to Joomla?

Joomla does not provide enough information when building pagination to output URLs such as /page-2, /page-3, etc.

It does include the rank of the first item on each page, but it does not provide the number of items per page.

Without that, the actual page number cannot be computed and so 4SEF must override Joomla code to also pass the number of items per page.

This can be fixed as follows:

  • ensure 4SEF system plugin is ordered before Joomlart T3 system plugin
  • make sure to use 4SEF version 1.0.3 or more recent
  • using FTP or your hosting company file manager, open the file /libraries/weeblr/forsef_functions.php (create it if it does not exist)
  • At the top of that file, make sure you see:
<?php
/**
 * 4SEF hooks file
 *
 * You can use 2 variables to access 4SEF content:
 *
 * $factory: access variables
 * $hooks: add handlers
 */

// no direct access
defined('WBLIB_EXEC') || die;
  • at the bottom of that file, add the following:
/**
 * Filter path to pagination chromePath file.
 *
 * @package 4SEF\filter\content
 * @var forsef_pagination_chrome_path
 * @since   1.0.3
 *
 * @param string $rules Path to an (optional) pagination chrome file.
 *
 * @return string
 *
 */
$hooks->add(
    'forsef_pagination_chrome_path',
    function ($chromePath) {

        $pathHelper = JPATH_ROOT . '/plugins/system/t3/includes/core/path.php';
        if (file_exists($pathHelper))
        {
            include_once $pathHelper;
            $chromePath = \T3Path::getPath('html/pagination.php');
        }

        return $chromePath;
    }
);

As always with code, a simple mistake such as a misplaced comma or space can cause a fatal error and kill the site.

If this happens, you can totally disable this change by renaming the forsef_functions.php file to anything else, for instance disabled_forsef_functions.php.

Changing the file name will immediately cause it to have no effect at all.