[wp-trac] Re: [WordPress Trac] #9741: Database issue allows creation of articles

WordPress Trac wp-trac at lists.automattic.com
Tue May 19 13:05:01 GMT 2009


#9741: Database issue allows creation of articles
----------------------------+-----------------------------------------------
 Reporter:  davehope        |        Type:  enhancement    
   Status:  new             |    Priority:  normal         
Milestone:  Future Release  |   Component:  Upgrade/Install
  Version:  2.8             |    Severity:  normal         
 Keywords:  needs-patch     |  
----------------------------+-----------------------------------------------

Comment(by Denis-de-Bernardy):

 improved version of the latter function:


 {{{
         function maintain_db() {
                 global $wpdb;

                 $tablelist = $wpdb->get_results("SHOW TABLE STATUS LIKE
 '$wpdb->prefix%'", ARRAY_N);

                 foreach ( $tablelist as $table ) {
                         $tablename = $table[0];

                         if ( strtoupper($table[1]) != 'MYISAM' )
                                 continue;

                         $check = $wpdb->get_row("CHECK TABLE $tablename",
 ARRAY_N);

                         if ( $check[2] == 'error' ) {
                                 $repair = $wpdb->get_row("REPAIR TABLE
 $tablename", ARRAY_N);

                                 if ( $repair[3] != 'OK' )
                                         continue;
                         }

                         $wpdb->query("OPTIMIZE TABLE $tablename");
                 }
         } # maintain_db()
 }}}

 it's on a weekly cron.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9741#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list