Site very slow after code modifying

Free responsive Joomla 2.5 and 3.x module to present your content with easy and intuitive way.
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Wed Mar 29, 2017 11:34 am
I'm using "news pro gk4" but the original code doesn't allow me to read contents coming from "k2 additional categories plugin". In order to show articles also on news pro gk4 module I modified gksourcek2.php file but after that modification the site appears very slow while if I use the original gksourcek2.php the site it's very fast!

Here the modified code:
Code: Select all
function getArticles($categories, $config, $amount) {
// mainframe
$sql_where = '';
$tag_join = '';
//
if($categories) {
$j = 0;
// getting categories ItemIDs
foreach ($categories as $item) {
//Additional Categories for K2
$sql_where .= ($j != 0) ? ' OR content.catid = '.$item->ID.' OR ca.catid ='.$item->ID : ' content.catid = '.$item->ID.' OR ca.catid ='.$item->ID;
//Additional Categories for K2
$j++;
}
}
// Arrays for content
$content_id = array();
$content_alias = array();
$content_cid = array();
$content_title = array();
$content_text = array();
$content_date = array();
$content_date_publish = array();
$content_author = array();
$content_cat_name = array();
$content_cat_alias = array();
$content_hits = array();
$content_email = array();
$content_authorid = array();
$content_rating_sum = array();
$content_rating_count = array();
$content_plugins = array();
$news_amount = 0;
// Initializing standard Joomla classes and SQL necessary variables
$db = JFactory::getDBO();
$user = JFactory::getUser();
$aid = max ($user->getAuthorisedViewLevels());
$date = JFactory::getDate("now", $config);
$now = $date->toMySQL();
$nullDate = $db->getNullDate();
// Overwrite SQL query when user set IDs manually
if($config == 'k2_articles' && $config != ''){
// initializing variables
$sql_where = '';
$ids = explode(',', $config);
//
for($i = 0; $i < count($ids); $i++ ){
// linking string with content IDs
$sql_where .= ($i != 0) ? ' OR content.id = '.$ids[$i] : ' content.id = '.$ids[$i];
}
}
// Overwrite SQL query when user specified tags
if($config == 'k2_tags' && $config != ''){
// initializing variables
$sql_where = '';
$tag_join = ' LEFT JOIN #__k2_tags_xref AS tx ON content.id = tx.itemID LEFT JOIN #__k2_tags AS t ON t.id = tx.tagID ';
// getting tag
$sql_where .= ' t.id = '. $config;
}

//Additional Categories for K2
$tag_join .=' LEFT JOIN #__k2_additional_categories AS ca ON content.id = ca.itemID ';

// if some data are available
if(count($categories) > 0){
// when showing only frontpage articles is disabled
$featured_con = ($config == 0) ? (($config == 0) ? ' AND content.featured = 0 ' : '' ) : ' AND content.featured = 1 ';
$since_con = '';
if($config !== '') $since_con = ' AND content.created >= ' . $db->Quote($config);
// Ordering string
$order_options = '';
// When sort value is random
if($config == 'random') {
$order_options = ' RAND() ';
} else { // when sort value is different than random
if($config != 'fordering') $order_options = ' content.'.$config.' '.$config.' ';
else $order_options = ' content.featured_ordering '.$config.' ';
}

if($config != 'all_k2_articles') {
$sql_where = ' AND ( ' . $sql_where . ' ) ';
}
// creating SQL query
$query_news = '
SELECT DISTINCT
cats.name AS cat_name,
cats.alias AS cat_alias,
content.catid AS cat_id,
'.((($config != 2) ? 'users.'.(($config == 1) ? 'username':'name') : 'content.created_by_alias')) .' AS author,
users.email AS author_email,
users.id AS author_id,
'.($config ? 'content.alias' : 'content.title').' AS title,
content.introtext AS text,
content.created AS date,
content.publish_up AS date_publish,
content.id AS ID,
content.alias AS alias,
content.hits AS hits,
content_rating.rating_sum AS rating_sum,
content_rating.rating_count AS rating_count,
content.plugins AS plugins
FROM
#__k2_items AS content
LEFT JOIN
#__k2_categories AS cats
ON cats.id = content.catid
LEFT JOIN
#__users AS users
ON users.id = content.created_by
'.$tag_join.'
LEFT JOIN
#__k2_rating AS content_rating
ON content.id = content_rating.itemID
WHERE
content.trash = 0'.(($config == 0) ? '
AND cats.access <= ' .(int) $aid . '
AND content.access <= '.(int) $aid : '').'
AND content.published = 1
AND cats.published = 1
AND ( content.publish_up = '.$db->Quote($nullDate).' OR content.publish_up <= '.$db->Quote($now).' )
AND ( content.publish_down = '.$db->Quote($nullDate).' OR content.publish_down >= '.$db->Quote($now).' )
'.$sql_where.'
'.$featured_con.'
'.$since_con.'
ORDER BY
'.$order_options.'
LIMIT
'.($config).','.$amount.';
';

//echo $query_news;
// run SQL query
$db->setQuery($query_news);
// when exist some results
if($news = $db->loadObjectList()) {
// generating tables of news data
foreach($news as $item) {
$content_id[] = $item->ID; // news IDs
$content_alias[] = $item->alias; // news aliases
$content_cid[] = $item->cat_id; // news CIDs
$content_title[] = $item->title; // news titles
$content_text[] = $item->text; // news text
$content_date[] = $item->date; // news dates
$content_date_publish[] = $item->date_publish; // news dates
$content_author[] = $item->author; // news author
$content_cat_name[] = $item->cat_name; // news category name
$content_cat_alias[] = $item->cat_alias; // news category alias
$content_hits[] = $item->hits; // news hits
$content_email[] = $item->author_email; // news author email
$content_authorid[] = $item->author_id; // news author id
$content_rating_sum[] = $item->rating_sum; // news rating sum
$content_rating_count[] = $item->rating_count; // news rating count
$content_plugins[] = $item->plugins; // news K2Store values
$news_amount++;   // news amount
}
}
}
// Returning data in hash table
return array(
"ID" => $content_id,
"alias" => $content_alias,
"CID" => $content_cid,
"title" => $content_title,
"text" => $content_text,
"date" => $content_date,
"date_publish" => $content_date_publish,
"author" => $content_author,
"cat_name" => $content_cat_name,
"cat_alias" => $content_cat_alias,
"hits" => $content_hits,
"email" => $content_email,
"author_id" => $content_authorid,
"rating_sum" => $content_rating_sum,
"rating_count" => $content_rating_count,
"plugins" => $content_plugins,
"news_amount" => $news_amount
);
}


Someone could help me? Do you have an idea about this issue?
Thanks
Paolo
User avatar
Junior Boarder

Joshua M
Fri Mar 31, 2017 12:03 pm
Hi,
News Show Pro GK4 is not supported anymore.. try to use GK5 version instead.
User avatar
Moderator

GK User
Mon Apr 03, 2017 3:36 pm
I already tried with gk5 but the problem persists.
User avatar
Junior Boarder

Joshua M
Tue Apr 04, 2017 3:26 pm
Could you please provide me with your website FTP and back-end access via PM (click the “Private Message” text underneath my avatar) so that I may analyze it?
User avatar
Moderator

GK User
Wed Apr 05, 2017 1:32 pm
Sent
User avatar
Junior Boarder

GK User
Fri Apr 07, 2017 9:04 am
Do you have any news for me?
User avatar
Junior Boarder

Joshua M
Fri Apr 07, 2017 12:24 pm
Please send me also backend access to your website (yourdomain.com/administrator)
User avatar
Moderator

GK User
Fri Apr 07, 2017 3:44 pm
Sent
User avatar
Junior Boarder

Joshua M
Mon Apr 10, 2017 7:44 am
Hi,

You are using Joomla 2.5.x. Unfortunately Joomla 2.5 support ended on December 31 2014, so unfortunately we can't help with your issue. It's recommended to update your version to 3.6 because of security and other possible issues.
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.