WordPress.org

Ready to get started?Download WordPress

Forums

WP Clean Up
Optimize not working in WP 3.9.x (5 posts)

  1. Adam Ainsworth
    Member
    Posted 2 months ago #

    No option to optimize DB and getting the error below

    Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in wp_clean_up_admin.php on line 368

    See screenshot for more detail https://www.dropbox.com/s/wn9q2ygcdr5mz2e/wp-cleanup-bug.jpg

    https://wordpress.org/plugins/wp-clean-up/

  2. dawiyo
    Member
    Posted 1 month ago #

    I'm seeing the same error.

  3. khanman225
    Member
    Posted 1 week ago #

    The way WordPress runs some mysql queries has changed in 3.9 and mysql_query is deprecated in favor of mysqli.

    Replace these two spots in wp_clean_up_admin.php:

    line 108

    function wp_clean_up_optimize(){
        global $wpdb;
    	$wcu_sql = 'SHOW TABLE STATUS FROM '.DB_NAME;
    	$result = $wpdb->get_results($wcu_sql);
    	foreach($result as $row) {
    		$wcu_sql = 'OPTIMIZE TABLE '.$row->Name;
    		$wpdb->query($wcu_sql);
    	}
    }

    line 363

    global $wpdb;
    		$total_size = 0;
    		$alternate = " class='alternate'";
    		$wcu_sql = 'SHOW TABLE STATUS FROM <code>'.DB_NAME.'</code>';
    		$result = $wpdb->get_results($wcu_sql);
    
            foreach($result as $row) {
    
                $table_size = $row->Data_length + $row->Index_length;
                $table_size = $table_size / 1024;
                $table_size = sprintf("%0.3f",$table_size);
    
                $every_size = $row->Data_length + $row->Index_length;
                $every_size = $every_size / 1024;
                $total_size += $every_size;
    
                echo "<tr". $alternate .">
                        <td class='column-name'>". $row->Name ."</td>
                        <td class='column-name'>". $table_size ." KB"."</td>
                    </tr>\n";
                $alternate = (empty($alternate)) ? " class='alternate'" : "";
    
            }
  4. dawiyo
    Member
    Posted 1 week ago #

    I appreciate the reply but that didn't work for me. I wonder if it being Network Activated has anything to do with it.

  5. Adam Ainsworth
    Member
    Posted 1 week ago #

    Hasn't worked for me either, I'm just running a standard install of WP 3.9.1

Reply

You must log in to post.

About this Plugin

About this Topic