fl4p / WP-Filebase

WP-Filebase
http://wpfilebase.com/
34 stars 35 forks source link

Deprecated mysql function #12

Open foamrider opened 8 years ago

foamrider commented 8 years ago

Hi

Tried to upgrade to PHP7.0 on my WP site with WP-Filebase installed. Generated error caused by the deprecated mysql_close function in:

https://github.com/f4bsch/WP-Filebase/blob/8bb80a9a147262231d007810be43f1c03f2ce45a/classes/Download.php#L467

Also line 469.

Should be replaced with mysqli og pdo

fl4p commented 8 years ago

Hi, wpdb has no close, I created a ticket for that: https://core.trac.wordpress.org/ticket/34903

Wrapping it into a function_exists check is a workaround (leaving the db connection open):

        if(function_exists('mysql_close')) {
            global $wpdb;
            if(!empty($wpdb->dbh) && is_resource($wpdb->dbh))
                    @mysql_close($wpdb->dbh);
            else
                    @mysql_close();
        }