Menu Content

Support

> Forums, FAQs & Paid Support
Welcome, Guest
Username Password: Remember me

Profile for rgoncalves

  • OFFLINE
  • Time Zone: GMT +0:00
  • Local Time: 14:57
  • Posts: 8
  • Profile Views: 4194
  • Location: Unknown
  • Gender: Unknown
  • Birthdate: Unknown

Signature

Posts

Posts

emo
I still had quite a lot of database calls with the query

SELECT `catid` FROM `jos_content` WHERE `id` = '{id}'

So I extended a bit the class I developed and managed to reduce it drastically, again with only one more core code change.

As I noticed that throughout the core code it is common to see a plan B if the normal behavior fails I’ve also included the normal database call to the class, that will be made in case the static variable does not have the required value.

So summing up the 2 changes that need to be done (the one I posted last week + this new one)

File: components/com_sef/sef.ext.php
Line: 81
Find lines:
$query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2';$db->setQuery($query);$sefurls = $db->loadObjectList('Itemid');echo '<pre>'; print_r($sefurls);

Replace With:
/* [RG] reduce databse calls
$query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2';
$db->setQuery($query);
$sefurls = $db->loadObjectList('Itemid');
*/

include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid, $where);


File: /components/com_sef/sef_ext/com_content.php
Line: 226
Find:
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$db->setQuery($query);
$catid = $db->loadResult();

Replace by:
/* [RG] reduce database calls
$query = "SELECT `catid` FROM `#__content` WHERE `id` = '{$id}'";
$db->setQuery($query);
$catid = $db->loadResult();
*/

include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$catid = SefUrlsTable::getCatid($id);


The attached files should be placed in: /componenets/com_sef/sef.table.php

With the 2 changes I suggesting in this topic I was able to reduce the number of database calls from 636 (most of them SEF related) to just 35, and the Application afterRender time from an average of 0.8 seconds to 0.609 seconds which is a 25% improvement!

Of course these numbers will depend greatly of each of your websites, but I think that some work around this can make joomSEf an even better tool.

Attachment sef-20100628.zip not found

joomSEF slows down J ...
Category: JoomSEF 3
emo
there is an error in the code I sugest to change,
I missed a DS

so in sef.ext.php the original lines should be replaced with

include_once(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid);
joomSEF slows down J ...
Category: JoomSEF 3
emo
Sorry only noticed you replied to my post after I submitted the changes I did.

Thanks for your reply, I’m not really a fan of the caching anyway as it just brings another set of things that can go wrong specially on very frequently updated websites.

I think I managed to achieve a nice result with the changes I just proposed, but it would be very interesting to expand the use of this new class centralizing in it all the calls to the #__sefurls table, which could then make an even bigger impact
joomSEF slows down J ...
Category: JoomSEF 3
emo
I tried to find a way and I was able to reduce significantly the number of database calls which also has a nice impact in the time Joomla takes to render :)

The changes are as follows

File: components/com_sef/sef.ext.php
Line: 81
Find lines:
$query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2';
$db->setQuery($query);
$sefurls = $db->loadObjectList('Itemid');
echo '<pre>'; print_r($sefurls);

Replace with:
include_once(JPATH_ROOT . 'components' . DS . 'com_sef' . DS . 'sef.table.php');
$sefurls = SefUrlsTable::getSefUrl($origurl, $Itemid);


It also requires a new file, with the SefUrlTable class, that you can find attached.

I've just coded it, and tested a few pages. But any feedback would be greatly appreciated

Attachment sef.zip not found

joomSEF slows down J ...
Category: JoomSEF 3
emo
With joomSEf enabled Joomla takes 1 full extra second to render the page. When I activated the debug I noticed that 720 more queries were being done that when SEF is disabled. 90% of these queries are as follows:
SELECT * 
FROM `jos_sefurls`
WHERE `origurl` = 'index.php?option=com_content&catid=102&id=521&view=article'
AND (`Itemid` = '1167' OR `Itemid` IS NULL)
LIMIT 2
 

Has anyone else experienced this?

I tried to activate the cache, but the number of queries didn’t reduced, not even when I lowered the Minimum cache hits count to 1!! So probably there is a problem in the way I’ve set up the cache, but I can’t figure out what:
Cache Configuration
Use cache? Yes
Maximum cache size: 1000
Minimum cache hits count: 1 (most of the links in that same page are unique)
Record hits for cached URLs: No
Display error if cache gets corrupted: No


Anyway, I don’t believe that making a request every time joomSEF needs to check if a link already has an SEF version is efficient. Therefore I would like to propose some code changes to improve its performance.
The idea is to get all the sefurls records before hand to a static variable and then we would only need to check that variable on every request.
joomSEF slows down J ...
Category: JoomSEF 3
emo
That’s great news David :)

Another thing that I’m willing to put some time into is to extend the variable sanitization to include post variables as well and the possibility for the admin to be alerted when something gets blocked that is a excellent way to fine-tune the settings.

The idea is to use the current variable filtering interface but to inbuilt the possibility to define if it is a post or a get variable.

Would you guys be interested in something like this?

If so, I would like to offer my help to the project.
URL did not pass the ...
Category: JoomSEF 3
emo
I matured the code a bit further and came up with the following

in components/com_sef/joomsef.php line 1203
replace this
if( $params->get('varFilterFail', '0') == '1' ) {
// We need to test the URL using variable filter
// in order to stop its further processing in case it fails
$failedVars = array();
if( !JoomSEF::_varFilterTest($uri, $failedVars) )
{
die($uri->toString() . '<br />' . JText::_('URL did not pass the variable filter test.'));
}
}


for this
if( $params->get('varFilterFail', '0') == '1' ) {
// We need to test the URL using variable filter
// in order to stop its further processing in case it fails
$failedVars = array();
if( !JoomSEF::_varFilterTest($uri, $failedVars) )
{
// redirect to the error page
if ($sefConfig->showMessageOn404) {
$mosmsg = 'FILE NOT FOUND: '.$route;
$mainframe->enqueueMessage($mosmsg);
}
else $mosmsg = '';
 
$link = '';
if ($sefConfig->page404 == '0') {
$db = JFactory::getDBO();
$sql = 'SELECT `id` FROM `#__content` WHERE `title`= "404"';
$db->setQuery($sql);
 
if (($id = $db->loadResult()))
$link = 'index.php?option=com_content&view=article&id=' . (int) $id;
}
elseif ($sefConfig->page404 == '9999999') {
$menu =& JSite::getMenu(true);
$item = $menu->getDefault();
$link = $item->link;
}
else {
$id = $sefConfig->page404;
$link = 'index.php?option=com_content&view=article&id=' . (int) $id;
}
 
// If custom Itemid set, use it
if ($sefConfig->use404itemid) {
$link .= '&Itemid=' . $sefConfig->itemid404;
}
 
//JoomSEF::_sendHeader('HTTP/1.0 506 Proxy Authentication Required'); //so it does not make sense mixed 506 with 407 error codes
header("HTTP/1.0 404 Not Found");
 
if ($link)
{
 
// Try to find the non-SEF URL in the database - don't create new!
$oldDisable = $sefConfig->disableNewSEF;
$sefConfig->disableNewSEF = true;
$sef = JRoute::_($link);
// Restore the configuration
$sefConfig->disableNewSEF = $oldDisable;
 
$f = $l = '';
if( !headers_sent($f, $l) )
{
$mainframe =& JFactory::getApplication();
$mainframe->redirect($sef, $mosmsg, 'error');
exit();
} else {
JoomSEF::_headers_sent_error($f, $l, __FILE__, __LINE__);
}
}
 
die($uri->toString() . '<br />' . JText::_('URL did not pass the variable filter test.'));
}
}


this will consider all the scenarios for the 404 error page:
- pointing to an existing article
- pointing to homepage
- default 404 page

I was not able to change the response headers to something like 404 or 500 but I think it would be easy for the joomSEF team to do that bit.

As I said earlier I think this could be a nice thing to have as it looks a lot better than a
die($uri->toString() . '<br />' . JText::_('URL did not pass the variable filter test.'));

But I would like to ear other opinions,
specially from the joomsef development team.

Regards
URL did not pass the ...
Category: JoomSEF 3
emo
Hi,
First of all congratulations for the excellent job you guys have put in place. I’ve downloaded the free edition today, and I love everything I’ve seen till now.
One of the decisive factors to pick joomSEF was the variable filtering, and it is here where I’m focusing my testing. It is definitely a very exciting feature and I’m seeing it as an extra security layer in my joomla site.
Unfortunately I came upon something that in my opinion could be better.
Having set same basic rules, and told SEF to ‘not process at all’, I get a page with the following page:
Content: www.websites.com/index.php?vars... URL did not pass the variable filter test.
Response code: 200
Well in my opinion it shouldn’t be a 200 but a 40x or even 50x, and also there should be a possibility to point the site to whatever error page was set in the main joomSEF configuration.
I think something like the following should be enough (/components/com_sef/joomsef.php)
if( !JoomSEF::_varFilterTest($uri, $failedVars) )
{
 
if ($sefConfig->page404 > 0)
{
//need to retrieve the page
$link = ...
global $mainframe;
$mainframe->redirect($link, '', 404);
 
}
 
die($uri->toString() . '<br />' . JText::_('URL did not pass the variable filter test.'));
}

Do you think we could have this in the future releases?
URL did not pass the ...
Category: JoomSEF 3
More
User Login Empty