Topic-icon Compatibility Issue with sh404SEF Error Page Handling

Active Subscriptions:

None
8 years 4 months ago - 8 years 4 months ago #56373 by altitudes
Hello

I have an issue with sh404SEF handling 404 error page, and from component developper's investigations, the problem seems to be on JFBConnect side, requiring a minor code change. Would you consider including it in next JFBConnect release?

Symptom
404 error page is empty (displays Joomla template with empty component area)

The following is needed for the problem to occur
- JFBConnect installed
- sh404SEF installed and set to handle 404 error page (that is: when a 404 error occurs, a page corresponding to configured item menu is displayed)
- Template is set to remove component output from homepage (which is often useful to have only modules on homepage)

Issue analysis by sh404SEF component developper

Weeblr wrote: Actually, after much digging, downloading a backup and debugging step by step, I found it's not the template. It's JFBConnect causing this (though I don't blame them entirely, the Joomla router is not doing a proper job there).

The full story is this:

- JFB has an OpenGraph plugin. This plugin is fired when the document is rendered, probably to insert OpenGraph meta data
- on line 214 of the file /components/com_jfbconnect/models/opengraphaction.php, they do:

$queryVars = $router->parse($juri);

This causes the Joomla router to reset the Itemid. So instead of using our 404 error page Itemid, JFBConnect causes the Itemid to be reset to the home page, and the content is not displayed.

This can be fixed by replacing the above code with, for instance:
$queryVars = JFactory::getApplication()->input->get->getArray();

which is the correct way according to Joomla API.


Thanks
Last edit: 8 years 4 months ago by altitudes.
The topic has been locked.
Support Specialist
Thanks for the detailed description of the problem and feedback from the sh404SEF developers. I've taken note of the issue and we'll definitely investigate the code change for the next release. Without testing, I can't guarantee it will be in that release, but if it works across all extensions and without sh404SEF and doesn't introduce any new issues, we'll gladly implement it.

If you run into anything else or have any other questions, please let us know.

Thanks,
Alex
The topic has been locked.
Support Specialist
I just investigated the code a bit more after our discussion in your other thread . It seems like sh404SEF is overriding the core-Joomla router, but not doing a full implementation. Our code looks like:
$queryVars = $router->parse($juri);

$jConfig->set('force_ssl', $forceSSL);

// Reset the router back to it's original state
$router->setVars($origVars);
The first line can reset the itemId as they note in their post. However, we do a lot of work to get the information about the current route first and then we use the setVars() function to reset the router back to its previous state. sh404SEF's router seems to ignore the setVars call. If they override a core function, they need to implement all the pieces and functions in that class or else bugs and incompatibilities will occur. We can't get around this in our code because, as you saw, using the method they provided introduced a slew of other problems where the Open Graph plugins don't work at all.

I hope that helps explain,
Alex
The topic has been locked.
Active Subscriptions:

None
Hello

Here is the answer I got from sh404SEF developer. All this is too technical for me, and I (and he) suggest that you have this (very) technical debate by contacting him directly. I will give you his email in a private message.

Weeblr wrote:

alzander wrote: It seems like sh404SEF is overriding the core-Joomla router, but not doing a full implementation.

nope, we do NOT override the core router. We follow Joomla API and only set up buildRules and parseRules.

alzander wrote: However, we do a lot of work to get the information about the current route first and then we use the setVars() function to reset the router back to its previous state. sh404SEF's router seems to ignore the setVars call.

We do not ignore it. As per the above, you are actually calling Joomla original setVars() function, in Joomla router. This method is not modified or altered in any way by sh404SEF.

The problem is that calling setVars is NOT enough. It does reset (some) of the router state, but the router is unfortunately not "self-contained".When you do that, you only reset the router internal storage of variables, but you basically don't do anything else.
The problem is that the parse() method has side effects, external to the router itself:
$queryVars = $router->parse($juri);

This code actually reset the active menu in the Joomla menu object. In other words, you reset the current active menu globally for the whole app. Yes, Joomla should not to do that probably, but that's how it works. It's done in JRouterSite, in various locations:
if (isset($vars['Itemid']))
{
$this->menu->setActive($vars['Itemid']);
}

From reading your code, I understand the only you need is the current page query vars, which can be obtained safely through the Joomla API using:
$queryVars = JFactory::getApplication()->input->get->getArray();

I'm not sure what problem this very safe, read only method is causing to you. But I have spent quite some times stepping through the PHP code to be sure changing the currently active menu is causing the problem here.
As an alternate solution, maybe you could keep your current code, but in addition also reset the Itemid?
$router->setVars($origVars);
if(!empty($origVars['Itemid'])
{
JFactory::getApplication()->getMenu()->setActive($origVars['Itemid']);
}

The topic has been locked.
Support Specialist
We'll try to set aside some time to look into this. However, it will be some time. We don't have a recent copy of sh404SEF that we'll need to test with and this isn't an issue that any other users are running into that we've heard of, so it's not a high priority for us. You can try the code they mention above to see if that helps. It'd be the first thing we'd try when we get a chance, but again, make sure that no other features break.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
OK. If you need the latest version of sh404SEF, just ask and I will provide it to you (sh404SEF developer certainly would do too).
The topic has been locked.