[wp-trac] Re: [WordPress Trac] #9741: Database issue allows
creation of articles
WordPress Trac
wp-trac at lists.automattic.com
Fri May 8 17:27:50 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):
Personally, I use the following on a daily cron:
{{{
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' )
{
if ( $check[3] == 'The handler for the
table doesn\'t support check/repair' )
{
continue;
}
else
{
$repair = $wpdb->get_row("REPAIR
TABLE $tablename", ARRAY_N);
if ( $repair[3] != 'OK' )
{
continue;
}
}
}
$wpdb->query("OPTIMIZE TABLE $tablename");
}
} # maintain_db()
}}}
the repair is only triggered when there's an actual error, so as to never
get any loss of data -- when it gets fired, data is lost already, so might
as well try to retrieve as much as we can.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9741#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list