[Plugin: WordPress Download Monitor] Think Twice before using this plugin (WARNING) !!!
-
Hi all,
I was really happy when I downloaded this plugin and activated on my site. But my happiness couldn’t last for long.
As soon as you grow your categories, you will be able to see this plugin is strong enough to KILL your server. For example.. if you have 500 download categories then this plgin will run 800+ SQL queries to fetch even ONE download result on a single post page. If you are a bit familiar with the programming and server resources, then you can assume the BLUNDER.
When I saw this this.. I was shocked and then I realized that we should think twice before activating any plugin like this.
Anyway.. I spent few time with this plugin and customized it completely and now it is working the way I wanted.
My advice would be.. DO NOT USE it.. tell the author to modify the coding ASAP.
Regards
-
Thats really clever. Rather than tell me, or contribute, you rant, thus reducing the user base, thus putting me off updating in the future. Genius.
jolley_small
No, I am not doing any clever trick here. I just warned about what I faced.
As far as putting updates here is concerned, I have updated plugin for my use and i discarded so many things which i didn’t need. So putting that update here will confuse people.
If you want, you can tell the author to see the issues which I have pointed and then he can update it accordingly.
This is a very serious issue and I am not sure why anyone didn’t notice it so far.
Just try to make 600 categories in it and then you will know what i mean. 600 data is nothing as far as PHP parsing and mysql load is concerned. But for this plugin 600 is like putting mote than 5 million data in the database. It will try to retrieve those categories in a way like it is trying to retrieve 5 millions entries from database.
A BIG NO NO for this plugin.
Regards
TabishSorry jolley_small I didn’t know you are the author.
you can mail me so that i can tell you the issues.
Regards
Ill be looking into the issue shortly – I should be able to find it.
Thanks
Jolley_small
Can you tell me what you are trying to achive here?
// select all cats
$query_select = sprintf(“SELECT * FROM %s ORDER BY id;”,
$wpdb->escape($wp_dlm_db_cats));$cats = $wpdb->get_results($query_select);
if (!empty($cats)) {
$patts = array();
$subs = array();foreach($cats as $c) {
// Get downloads for cat and put in ul
$links = ‘- ‘;
// Get list of cats and sub cats
$the_cats = array();
$the_cats[] = $c->id;
$query = sprintf(“SELECT id from %s WHERE parent IN (%s);”,
$wpdb->escape( $wp_dlm_db_cats ),
$wpdb->escape( implode(“,”,$the_cats) ));
$res = $wpdb->get_results($query);
$b=sizeof($the_cats);
if ($res) {
foreach($res as $r) {
if (!in_array($r->id,$the_cats)) $the_cats[]=$r->id;
}
}
$a=sizeof($the_cats);
while ($b!=$a) {
$query = sprintf(“SELECT id from %s WHERE parent IN (%s);”,
$wpdb->escape( $wp_dlm_db_cats ),
$wpdb->escape( implode(“,”,$the_cats) ));
$res = $wpdb->get_results($query);
$b=sizeof($the_cats);
if ($res) {
foreach($res as $r) {
if (!in_array($r->id,$the_cats)) $the_cats[]=$r->id;
}
}
$a=sizeof($the_cats);
}This you can get in wp_dlm_parse_downloads_cats() in wp_download_monitor.php file.
What are you trying to archive in this loop dude?
Regards
TabishIts a bad loop getting sub cats. I’ve improved efficiently in latest build.
Good thing..
But still it’s as bas as it was before.
Why are you using
$query_select = “SELECT * FROM “.$wpdb->escape($wp_dlm_db_cats).” ORDER BY id;”; in wp_dlm_parse_downloads_cats() .. so again in
foreach($cats as $c) {
// Get downloads for cat and put in ul IF WE FIND IT IN THE DATA
if ( strstr($data, “[download_cat#”.$c->id.”]” ) ) {That means again.. we have 800 categories.. it will run it 800 times..
Why you are doing so.. i dont understand..
My simple input for you would be:
<? function wp_dlm_parse_downloads_cats($data) { if (substr_count($data,"[download_cat#")) { preg_match_all("|\[download_cat#(.*)\]|U",$data,$result,PREG_SET_ORDER); foreach ($result as $val) { $query ="SELECT * FROM wp_DLM_DOWNLOADS WHERE category_id=$val[1] ORDER BY 'title'"; $downloads = $wpdb->get_results($query); // now here you can convert the keyowrds into links.. or whatever you want to do here } } return $data; } ?>
This things can achieved by only two or three lines.. it can be more compact.. but I will have to use more mind.. which i cant do right now. π
Regards
Its because we cannot run code directly in the post – we have to get the category ID’s and check whether or not it is present in each post as a tag.
Yes.. i had an Idea what you are doing..
Did you get my code? it’s doing the same thing without selecting all the categories.
Regards
Tabishi agree with tabish to many queries this thing kinda sucks it needs simplified
sorry but after futher testing this thing sux worse than previously thought before boooooooooooooooooooo
Yes.. razorcreed
I tried to make the author (jolley_small) understand but it looks like he is being hurt if someone points his err. You can see his first reply to me.. it was real Rude.
and now when I am giving him the solution, he looks like no more interested in any suggestions.
I wish if WordPress has some sort of “Check” for these kind of plugins.. which can easily kill your site and server.
The worst thing is.. i have pointed only about one function.. even when you go to the Write Post page, download monitor will rum 800 SQL queries if you have more than 400 categories in it..
So whole plugin needs to be re-written.
Hi jolley_small/tabish,
There’s no denying that the concept for this plugin is a good one. Is there no way that you can sort you differences out and come up with a bullet proof solution? It wouldn’t take too much surely?
easy
vektor.
“I tried to make the author (jolley_small) understand but it looks like he is being hurt if someone points his err. You can see his first reply to me.. it was real Rude.”
FYI the topic title was discouraging anyone using the plugin, which I found rude considering the effort that went into it.
May I remind everyone this is offered for free off of my own back so why complain and say it sucks?
@tabish I appreciate your input, I’m trying to make it all work. The latest update was a temp improvement but obviously will need more work.
Categories were thrown in at a later stage – thats why they are a bit messed up.Hi Tabish,
If this works out well Ill mod all the queries in a similar fashion. Heres what I have come up with. I had to modify the query since we need to get the category and its sub-categories by traversing through.
function wp_dlm_parse_downloads_cats($data) { if (substr_count($data,"[download_cat#")) { global $wpdb,$wp_dlm_root,$allowed_extentions,$max_upload_size,$wp_dlm_db,$wp_dlm_db_cats; $patts = array(); $subs = array(); $url = get_option('wp_dlm_url'); $downloadurl = get_bloginfo('wpurl').'/'.$url; if (empty($url)) $downloadurl = $wp_dlm_root.'download.php?id='; $downloadtype = get_option('wp_dlm_type'); // Get cats and dig for sub cats function get_sub_cats($the_cats) { global $wpdb, $wp_dlm_db_cats; $a=sizeof($the_cats); $query = sprintf("SELECT id from %s WHERE parent IN (%s);", $wpdb->escape( $wp_dlm_db_cats ), $wpdb->escape( implode(",",$the_cats) )); $res = $wpdb->get_results($query); if ($res) { foreach($res as $r) { if (!in_array($r->id, $the_cats)) $the_cats[]=$r->id; } } $b=sizeof($the_cats); if ($a!=$b) { $sub_cats = get_sub_cats($the_cats); $the_cats = $the_cats + $sub_cats; } return $the_cats; } preg_match_all("|\[download_cat#(.*)\]|U",$data,$result,PREG_SET_ORDER); foreach ($result as $val) { // Traverse through categories to get sub-cats $the_cats = array(); $the_cats[] = $val[1]; $the_cats = get_sub_cats($the_cats); // Get downloads for category and sub-categories $query ="SELECT * FROM $wp_dlm_db WHERE category_id IN (".implode(',',$the_cats).") ORDER BY 'title'"; $downloads = $wpdb->get_results($query); // GENERATE LIST $links = '<ul>'; if (!empty($downloads)) { foreach($downloads as $d) { switch ($downloadtype) { case ("Title") : $downloadlink = urlencode($d->title); break; case ("Filename") : $downloadlink = $d->filename; $link = explode("/",$downloadlink); $downloadlink = end($link); break; default : $downloadlink = $d->id; break; } if (!empty($d->dlversion)) $links.= '<li><a href="'.$downloadurl.$downloadlink.'" title="'.__("Version","wp-download_monitor").' '.$d->dlversion.' '.__("downloaded","wp-download_monitor").' '.$d->hits.' '.__("times","wp-download_monitor").'" >'.$d->title.' ('.$d->hits.')</a></li>'; else $links.= '<li><a href="'.$downloadurl.$downloadlink.'" title="'.__("Downloaded","wp-download_monitor").' '.$d->hits.' '.__("times","wp-download_monitor").'" >'.$d->title.' ('.$d->hits.')</a></li>'; } } else { $links .= '<li>No Downloads Found</li>'; } $links .= '</ul>'; $patts[] = "[download_cat#" . $val[1] . "]"; $subs[] = $links; } $data = str_replace($patts, $subs, $data); } return $data; }
- The topic ‘[Plugin: WordPress Download Monitor] Think Twice before using this plugin (WARNING) !!!’ is closed to new replies.