We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

File

Development and Programming

tcuster's avatar
tcuster
5 posts
17 years ago
tcuster's avatar tcuster
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

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

Version 2.1.1 should resolve that issue tcuster.

       
tcuster's avatar
tcuster
5 posts
17 years ago
tcuster's avatar tcuster

Mark,

When I use the new version of the extension, my pages are all blank. If I comment out the mod, the pages display again.

Any ideas?

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

Did you have that problem with 2.1.0? What do you mean comment out the mod?

       
tcuster's avatar
tcuster
5 posts
17 years ago
tcuster's avatar tcuster

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.

       
Joey Trimmer's avatar
Joey Trimmer
128 posts
17 years ago
Joey Trimmer's avatar Joey Trimmer

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.

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

@joeyt – this was a problem with the object-ness of php4 vs. php5. i’ve since updated to version 2.1.2 which should take care of that.

       
Joey Trimmer's avatar
Joey Trimmer
128 posts
17 years ago
Joey Trimmer's avatar Joey Trimmer

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 Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

the first thing to check is your paths then permissions, make sure all your upload paths are the full path as reported in PHP Info under Admin » Utilities.

       
Joey Trimmer's avatar
Joey Trimmer
128 posts
17 years ago
Joey Trimmer's avatar Joey Trimmer

Thanks again, Mark, I really appreciate it. Using the full paths worked like a charm. I don’t remember having to do that before is it a case by case thing to check for this?

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

great, yea some servers are different like that, can’t say why. in general though I always go with the full path even though it makes it harder to migrate later.

       
Silencio's avatar
Silencio
46 posts
17 years ago
Silencio's avatar Silencio

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 Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

unfortunately each field can only have one image location. however have you set up your path in the admin » system pref » configuration page? That should drive the url of the image?

       
Thorvald's avatar
Thorvald
10 posts
17 years ago
Thorvald's avatar Thorvald

Mark,

You’ve got a subversion folder in the latest release. icons/.svn

Hidden … I wondered why it was taking so long to upload 😛

Thought you’d want to know.

       
DMT Media's avatar
DMT Media
12 posts
17 years ago
DMT Media's avatar DMT Media

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.

       
First 13 14 15 16 17 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.