Archive for the 'PHP' Category

12th May 2008

Открыта вакансия PHP-разработчика

Компании срочно требуются PHP-разработчики. Основные требования:

  1. Опыт работы в веб-программировании не менее двух лет
  2. Возраст не младше 21 года
  3. Знание ООП и отличий между PHP 4.x и PHP 5.x
  4. Желательно проживание в г. Харькове или г. Сумы

Подробности можно узнать, оставив комментарии к этому сообщению либо по ICQ: 142806591

Posted by Posted by Alexander Alfimov under Filed under Other, PHP Comments No Comments »

02nd Mar 2008

PHP 4.x annoying bug related to $this keyword

Did you know PHP 4.x cannot take reference from $this? So, code below won’t work:

$reference = &$this;

It took me about 30 minutes to figure out what exactly was wrong with my code. So, I hope this post will help somebody else to avoid the problem.

What I did to fix it. Just added another property named “reference” to class and initialized it right after creating class instance. If anybody knows another way - please let me know.

Thank you.

Posted by Posted by Alexander Alfimov under Filed under PHP Comments No Comments »

10th Nov 2007

Drupal, Wordpress and Joomla!: performance tests.

Hi!

Today I’d like to share some interesting results of performance tests for 3 most popular CMS/Blog systems: Drupal, Joomla! and WordPress.

Tests were done on dev debian machine using Apache ab utility.

MySQL settings:

| join_buffer_size | 131072 |
| key_buffer_size | 16777216 |
| key_cache_age_threshold | 300 |
| key_cache_block_size | 1024 |
| key_cache_division_limit | 100 |

| query_alloc_block_size | 8192 |
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 16777216 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |

Apache settings:

<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 20
MaxRequestsPerChild 0
</IfModule>

All systems have about 20,000 articles and 200+ links on page.

Versions: drupal 5.1, wordpress 2.2, joomla! 1.0.12

Results for ab -n 200 -c 4:

drupal-sef-no-aliases:
Requests per second: 2.43 [#/sec] (mean)

drupal-sef-20000-aliases:
Requests per second: 1.21 [#/sec] (mean)

joomla1-no-sef:
Requests per second: 2.75 [#/sec] (mean)

joomla1-patched-opensef:
Requests per second: 1.87 [#/sec] (mean)

wordpress-numeric-permalinks:
Requests per second: 0.65 [#/sec] (mean)

wordpress-date-name-permalinks:
Requests per second: 0.64 [#/sec] (mean)

Larger number means better performance. Joomla rocks?

Posted by Posted by Alexander Alfimov under Filed under CMS, Joomla, MySQL, PHP Comments 4 Comments »

06th Mar 2007

OpenSEF RC5 SP2 Perfomance Improvement

Hi, all!Recently I’ve rewritten a pretty large site on Joomla (it has about 200 online users all the time, as Joomla backend stats shows, >17000 content items etc.) and noticed that the page generation time started to grow ftom 0.101 secs to 0.5 after the first day, 0.7 - 1 next day…). Not very good, right? First of all I went to the MySQL console at the time of high loads and… voila - there is a `opensef_sef` MySQL query present almost constantly. Guys, can anybody explain me why do they fetch into the memory almost all records in sef.php [Line #173]:

if ($sefSite->id == null) $sefSite->id = -1;
$query = “SELECT * FROM #__opensef_sef WHERE published = ‘1′” .
“\nAND valid = ‘1′” .
“\nAND (direction IS NULL OR direction = ‘’ OR direction = ‘o’)” .
“\nAND (site_id IS NULL ” .
($sefSite->id ? ‘ OR site_id = ‘ . $sefSite->id : ‘’) . ‘)’ .
“\nORDER BY site_id DESC, published DESC, valid DESC, LENGTH(direction) DESC”;
$database->setQuery( $query );
if ($database->loadResult()) {
$opensef_aliases = $database->loadObjectList();
}

A quick fix is to replace the query with this one:

if ($sefSite->id == null) $sefSite->id = -1;
$query = “SELECT * FROM #__opensef_sef WHERE published = ‘1′” .
“\nAND valid = ‘1′” .
“\nAND (direction IS NULL OR direction = ‘’ OR direction = ‘o’)” .
“\nAND (site_id IS NULL ” .
($sefSite->id ? ‘ OR site_id = ‘ . $sefSite->id : ‘’) . ‘)’ .
“\nAND (external=’{$_SERVER[’REQUEST_URI’]}’” .
“\nORDER BY site_id DESC, published DESC, valid DESC, LENGTH(direction) DESC”;
$database->setQuery( $query );
if ($database->loadResult()) {
$opensef_aliases = $database->loadObjectList();
}

After that, find the lookupOutgoing function  in administrator/components/com_sef/sef.class.php and replace it with this one:

function lookupOutgoing( $site_id, $url ) { // static method
global $opensef_aliases, $database;

$returnaliases = array();
/*
if ($site_id == null) $site_id = -1;
if (count($opensef_aliases) > 0) {
foreach($opensef_aliases as $aliases){
if ( $aliases->internal == $url ) {
$returnaliases[] = $aliases;
}
}
}
*/
if (!count($returnaliases))
{
$query = “SELECT * FROM #__opensef_sef WHERE published = ‘1′” .
“\nAND valid = ‘1′” .
“\nAND (direction IS NULL OR direction = ” OR direction = ‘o’)” .
“\nAND internal=’$url’”.
“\nORDER BY site_id DESC, published DESC, valid DESC, LENGTH(direction) DESC limit 1″;

$database->setQuery( $query );
if ($database->loadResult())
{
$aliases = $database->loadObjectList();
foreach($aliases as $k=>$val)
{
$returnaliases[] = $val;
}
}
}

if (is_array( $returnaliases ) && count( $returnaliases )) {
$returnaliases = xclCastObjectList( $returnaliases, ‘JosOpenSEFAlias’ );
return $returnaliases[0];
}
$null = null;
return $null;
}

Hurray! It works as a charm. Page generation time is now 0.07 seconds.

Hope this will help somebody else.

Thanks.

Posted by Posted by Alexander Alfimov under Filed under CMS, Joomla, MySQL, OpenSEF, PHP Comments 1 Comment »

Close
E-mail It