File extension calls the database 252 times in a single page! The database is abused in this plugin. The db is queried even when you are accessing a MEMBER VARIABLE of the file class. I slightly modified the code to hold the previous results in a static class variable. The fetch_setting() method first checks the class variable before turning to the database. The modification brought the total number of queries down to 4 (from 250+).... var $docs_url = 'http://docs.markhuot.com'; //drch edit public static $uploadSettings; //end drch // //constructor ...
function fetch_setting( $upload_id, $setting ) { global $DB, $PREFS; /* drch edit */ if (!isset(self::$uploadSettings[$upload_id])) { $upload_pref = $DB->query("SELECT * FROM exp_upload_prefs WHERE id='".$upload_id."'"); self::$uploadSettings[$upload_id] = $upload_pref->row; } $row = self::$uploadSettings[$upload_id]; if(isset($row['properties']) && $row['properties'] != "") parse_str($row['properties']); $val = isset($row[$setting]) ? $row[$setting] : (isset($$setting) ? $$setting : (isset($this->settings[$setting]) ? $this->settings[$setting] : "")); /*end drch edit */ if($val == "") { switch($setting) { case "url": $val = preg_replace("/\/$/", "", $PREFS->core_ini['site_url'])."/images/uploads/"; break; case "server_path": $val = preg_replace("/\/$/", "", PATH).'/../images/uploads/'; break; case "store_thumbs_separately": $val = 'no'; break; case "thumb_width": $val = '200'; break; case "thumb_height": $val = '200'; break; case "allow_multiple": $val = 'no'; break; case "show_preview": $val = 'no'; break; } } if($val == 'yes') $val = true; else if($val == 'no') $val = false; return $val; }
Has the excessive query issue been resolved in the current version of the extension? I tried to use the code above but I can’t get it to work.
Thanks, Troy
In version 2.1.0, when I used the code modification posted by darylh to reduce the queries, my pages did not display. When I removed the modification, the page displayed fine. It looks like you used the same code in your latest version 2.1.1 - I am getting the same results - a blank page.
Hi there Mark.
Blank page here as well with the new 2.1.1. Before I upgraded I was getting another error trying to upload files so I was hoping this would fix that. Here’s what happens now:
If I disable the old extension before I upload the new one I get this exact error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /data/14/1/147/70/1310559/user/1403571/htdocs/ee/admin/extensions/ext.file.php on line 27
Otherwise, blank page.
Thanks Mark! The new version loaded correctly.
However I’m still encoutering a php error: “Warning: move_uploaded_file” The same as this person actually.
Any thoughts on what could cause this? File permissions all seem to be set correctly.
Mark, do you have any experience installing this extension on a multi-site ee install?
When I use this extension on different sites within the same ee install… the images all go to the same folder. I’d like to seperate each site’s upload location. Am I missing something… or is this not possible yet?
Thanks.
Mark, variable problem when your file extension is first in line… (first custom field added)
CP Home › Admin › Content Administration › Field Groups › Custom Fields
Notice: Undefined variable: field_type in /home/XXXX/domains/mysite.com/html/system/cp/cp.publish_ad.php on line 7311
Don’t know if this is you or EE.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.